RubyMine SSH remote interpreter within docker container.

We are trying to setup SSH remote interpreter to the local docker container to debug Rails application.

We don't want to use remote Docker interpreter since we need our container to run in background, and want occasionally run debug sessions within running container.

 

We do have ssh server run in container and able to connect remote ruby interpreter to it, but we can't run/debug anything using it. 
Other issue, we have an empty gem list in IDE for this interpreter.



We try to run the simplest possible setup now, generated Rails App Stub and standard ruby image: 

Dockerfile:

FROM ruby:2.3.0

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
nodejs \
openssl \
openssh-server

RUN echo "root:root" | chpasswd
RUN sed -i -e '/PermitRootLogin/ s/ .*/ yes/' /etc/ssh/sshd_config
RUN mkdir /var/run/sshd

RUN gem install bundler --no-ri --no-rdoc

RUN mkdir -p /app
WORKDIR /app

# copy src with Gemfile
ADD . /app
RUN bundle install

EXPOSE 3000 22

CMD ["/usr/sbin/sshd", "-D"]

Remote interpreter settings:

When we try to add this interpreter to Rails Run Configurations it fails to run with [No Rails found in SDK].

Again we do not try to use some special setup here, standard Ruby Image with bare generated rails scaffold app, so if you have a working setup it would be really awesome to see it. 


So the questions are: 
  Is it possible to run such setup at all?
  If so, what we were missing in our setup?

 

System Info:

RubyMine 2017.2.1
Build #RM-172.3544.29, built on July 28, 2017
Licensed to RubyMine Evaluator
Expiration date: September 7, 2017
JRE: 1.8.0_152-release-915-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6 

 

Thanks in advance

5 comments

Hello Ayrov, sorry for delay with answer. We managed to reproduce the problem. 

In your configuration gem installed to /usr/local/bundle. To get gem installation directory at remote host RubyMine uses command “gem env gempath”. This command returns wrong list of gem roots.

We are going to fix it by calling “bundle exec env gempath”. Fix will be available in one of the next releases of RubyMine. Please vote for https://youtrack.jetbrains.com/issue/RUBY-19828.

As workaround you could modify environment variables GEM_PATH, GEM_ROOT or BUNDLE_PATH in your Dockerfile. Found related discussion here: https://github.com/docker-library/ruby/issues/53. Let us know if you need help with it.

0

hi, I tried to specify GEM_PATH and GEM_ROOT (BUNDLE_PATH is already pointing to the right folder) in dockerfile so that `gem env gempath` gives the same path as `bundle exec gem env gempath` but with no luck, it doesn't solve issue with empty gem list.

Could you give me a more detailed description/instructions of what should be done here? 

0

Hello Alexander,

could you please try setting GEM_HOME and BUNDLE_PATH before 'bundle install' to /root/.gem/.. (your path). For example:

RUN mkdir -p /root/.gem/ruby/2.3.0
ENV GEM_HOME /root/.gem/ruby/2.3.0
ENV BUNDLE_PATH /root/.gem/ruby/2.3.0
0

Hi,

I tried but it breaks ruby in some way, and I'm not able to run bundle install, despite its installation on the step above.

Is it possible to get working dockerfile that I can use as a template for such setup?

Thanks,
Alex

0

Hi Alex,

sorry for the delay.

So first of all you need to turn rsync off (since there isn't any on the remote host), you can do it via Registry (Help | Find Action | Registry | ide.remote.interpreters.use.rynsc). You can also set the Ruby path to /usr/local/bin/ruby. 

Please note that path mappings need to be configured (p. 7): https://www.jetbrains.com/help/ruby/configuring-remote-interpreters-via-ssh.html 

Here is the Dockerfile:


FROM ruby:2.3.0

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
nodejs \
openssl \
openssh-server

RUN echo "root:root" | chpasswd
RUN sed -i -e '/PermitRootLogin/ s/ .*/ yes/' /etc/ssh/sshd_config
RUN mkdir /var/run/sshd

RUN gem install bundler --no-ri --no-rdoc

RUN mkdir -p /app
WORKDIR /app

# copy src with Gemfile
ADD . /app

RUN mkdir -p /root/.gem/ruby/2.3.0
ENV GEM_HOME /root/.gem/ruby/2.3.0
ENV BUNDLE_PATH /root/.gem/ruby/2.3.0

RUN bundle install

EXPOSE 3000 22

CMD ["/usr/sbin/sshd", "-D"]

 

0

Please sign in to leave a comment.