Remote SDK with Vagrant. No Gems listed.

RubyMine 6.0.3 is installed on my Mac.
I've got a Vagrant (Ubuntu) machine that can happily run my Rails app. Now, I'm trying to set up a fresh install of RubyMine to debug my Rails app on the Vagrant VM.

The remote SDK appears to be configured correctly inside of Rubymine. I added it (127.0.0.1, port 2222), and Rubymine detected that the version of Ruby is 2.1.0:
However, the gems list is empty. It says "nothing to show". Is that expected?
Other local rubies show their gems correctly.

A few random details:
The VM is using Puma based on Rubinius. Rubinius is installed here:
/opt/rubies/rubinius-2.2.3/
The Vagrant box is not using RVM or rbenv. I am just chruby, which is a lighter-weight way to switch rubies.

I use foreman to start Puma. Here's the procfile:
web: bundle exec puma -S ~/puma -C config/puma.rb

I'm purposefully ignoring some prompts to install missing gems since the gems are all installed remotely. I don't want to end up in a situation where i think everything is fine, but it's just because the gems are locally installed.
Do I need to install any gems locally to get this to work?

After I install the remote ruby SDK, it says "downloading gems", and appears to download some gems like "rake" and "ri".

Here's the "gem env" output when run in the VM:

> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.1
  - RUBY VERSION: 2.1.0 (2014-01-30 patchlevel 0) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /home/vagrant/.gem/rbx/2.1.0
  - RUBY EXECUTABLE: /opt/rubies/rubinius-2.2.3/bin/rbx
  - EXECUTABLE DIRECTORY: /home/vagrant/.gem/rbx/2.1.0/bin
  - SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
    - x86_64-rubinius-2.2
  - GEM PATHS:
     - /home/vagrant/.gem/rbx/2.1.0
     - /opt/rubies/rubinius-2.2.3/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/vagrant/.gem/rbx/2.1.0/bin
     - /opt/rubies/rubinius-2.2.3/gems/bin
     - /opt/rubies/rubinius-2.2.3/bin
     - /usr/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games

14 comments
Comment actions Permalink

Yes, rbenv does works.  You just need to select binary under .rbenv/versions directory.

Regrads, Oleg.

1
Comment actions Permalink

Hi,

this is deinitely not expected, but it is hard to say what is the cause of the problem :(
Could you please try remove/add the sdk and provide RM's logs (Help|Show Logs in ...).

Regards, Oleg.

0
Comment actions Permalink

Okay, adding a standard remote ruby that is simply /usr/bin/ruby works. That does indeed give me the remote gems installed. We're getting somewhere.

However, when Rubinius is the remote ruby, things don't work. I now believe I've run into two separate bugs. (Discovered some of this from this post:
http://spiridonov.pro/2012/09/18/rubinius-and-rubymine/ )

There are two bugs here:
1) Rubymine assumes that gem is a ruby script, rather than an executable. (That is not the case in Rubinius)
2) Rubymine assumes that all ruby interpreters take the "-C" and "-x" command line parameters. (Rubinius does not take the -x parameter)

Taking each bug in turn:

1) From the attached log files, I can see that RubyMine is NOT simply running the "gem" command. Instead, it's doing this:
2014-02-05 11:55:04,324 [ 518782]   INFO - esdk.transport.JschExecProcess - Executing ssh command: env "JETBRAINS_REMOTE_RUN"="1" "RM_INFO"="RM-133.632" "LANG"="en_US.UTF-8" "PATH"="/opt/rubies/rubinius-2.2.4/bin:/usr/local/bin:$PATH" /opt/rubies/rubinius-2.2.4/bin/ruby -C'/opt/rubies/rubinius-2.2.4/bin' -x /opt/rubies/rubinius-2.2.4/bin/gem environment gempath for vagrant@127.0.0.1:2522

Simplified, that's equivalent to:
ruby -x /opt/rubies/rubinius-2.2.4/rubymine/gem

In Rubinius, gem is not a ruby file. It's an executable that is symlinked to the rbx executable. When you run it, the rbx executable says "Oh, they were running the gem command, so I'll execute gem instead of executing rbx..."
So, passing in the "gem" file to Rubinius won't work.

2) Even if that did work, Rubymine passes the "-x" parameter to ruby, which, in a standard interpreter says "strip off text before #!ruby line and perhaps cd to directory"
But Rubinius doesn't take a "-x" parameter, which causes an error.

I believe I can fix this by making a "fake" ruby executable that will be compatible with RubyMine's assumptions, as the authors of the above-linked post have done. I will report back on that soon.
In the meantime, I assume that these are not known issues, and Rubymine claims to be compatible with Rubinius. Where should I report these bugs?

Many thanks,

Taylor



Attachment(s):
idea.log.zip
0
Comment actions Permalink

Hi,

there is a ticket about supporting debugging with Rubinius 2.X (http://youtrack.jetbrains.com/issue/RUBY-14118)  but I'm not sure when it will be done
since (as far as I know) rubinius' debugging API doesn't allow us to implement some simple features such as step-into (and some others).
But I have failed to find any tickets about other problems you found.  Could you please file a new ticket for this.

Thanks in advance, Oleg.

0
Comment actions Permalink

Hi,

I've investigate the problem with "-x" param and it looks like the problem was specific to remote rubinius.
And it looks like I've found the cause and fixed it.  The fix will be available in our next/first EAP build for RubyMine Hinoki (6.5) which should be available in couple weeks.

Regards, Oleg.

0
Comment actions Permalink

Thanks Oleg. Does RubyMine support remote debugging with JRuby?

I was able to trick RubyMine into working with Rubinius, at least as far as initial Gem detection is concerned.

I created a new folder in my ruby installation called "rubymine", and created two files in there: gem, and ruby

These are wrappers around the "real" ruby and gem, but they fake enough to convince RubyMine that this is a ruby installation it's expecting to see.

Here are the contents of "/home/vagrant/.rvm/rubies/rbx-2.2.4/rubymine/gem":

#!/home/vagrant/.rvm/rubies/rbx-2.2.4/bin/ruby

exec("/home/vagrant/.rvm/rubies/rbx-2.2.4/bin/gem", *ARGV)




And here are the contents of "/home/vagrant/.rvm/rubies/rbx-2.2.4/rubymine/ruby":

#!/home/vagrant/.rvm/rubies/rbx-2.2.4/bin/ruby

#First, strip off the -x argument, since Rubinius doesn't know it
ARGV.delete_if {|argument| argument == "-x"}

exec("/home/vagrant/.rvm/rubies/rbx-2.2.4/bin/ruby", *ARGV)


Then, I point rubymine at that new fake ruby: /home/vagrant/.rvm/rubies/rbx-2.2.4/rubymine/ruby

That correctly installs gems, lists gems, etc. I'm still struggling to get it to run my app on the remote machine, but I believe that is a separate issue.

To fix this, I think that RubyMine shouldn't make so many assumptions about how ruby and gem interact, and should attempt to run those commands separately. I'll file a bug.

0
Comment actions Permalink

Hi,

we do support remote and local debugging for jruby.  Actually remote doesn't add anything here, if we can debug something locally then we can debug it remotely.
The problem with Rubinius is that the API it provides doesn't allow us to implement some basic functions (such as step-into)  (or we have just missed the way it should be doen ;)
But we do working on it.

Regards, Oleg.

0
Comment actions Permalink

Thanks for the quick replies and the fix Oleg. That's great!

If anyone else is following, you can see the bug (now resolved) here: http://youtrack.jetbrains.com/issue/RUBY-14920

0
Comment actions Permalink

Thank you.  For me it was interesting research project ;)

0
Comment actions Permalink

I'm getting a similar problem but with MRI, Rubymine is able to detect the remote SDK  in the vagrant box but not the gems.

My box setup is
- virtual box
- Vagrant
- Ubuntu precise 64
- RVM
- Ruby 1.9.3-p448@eventfuelserver  (the default gemset)

I'm running mac osx 10.7.5 and Rubymine 6.0.3


Some outputs

vagrant@rails-dev-box:~$ gem env

RubyGems Environment:

  - RUBYGEMS VERSION: 2.2.2

  - RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-linux]

  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p448@eventfuel-server

  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby

  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p448@eventfuel-server/bin

  - SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs

  - RUBYGEMS PLATFORMS:

    - ruby

    - x86_64-linux

  - GEM PATHS:

     - /usr/local/rvm/gems/ruby-1.9.3-p448@eventfuel-server

     - /usr/local/rvm/gems/ruby-1.9.3-p448@global

  - GEM CONFIGURATION:

     - :update_sources => true

     - :verbose => true

     - :backtrace => false

     - :bulk_threshold => 1000

  - REMOTE SOURCES:

     - https://rubygems.org/

  - SHELL PATH:

     - /usr/local/rvm/gems/ruby-1.9.3-p448@eventfuel-server/bin

     - /usr/local/rvm/gems/ruby-1.9.3-p448@global/bin

     - /usr/local/rvm/rubies/ruby-1.9.3-p448/bin

     - /usr/local/sbin

     - /usr/local/bin

     - /usr/sbin

     - /usr/bin

     - /sbin

     - /bin

     - /usr/games

     - /usr/local/rvm/bin



The idea.log after I tried to add the remote SDK (the paths in bold I couldnt locate in my box, not sure if they should be there or not)


2014-02-07 09:35:34,604 [37795460]   INFO - sdk.transport.SshRemoteSession - New ssh session created: vagrant@127.0.0.1:2222
2014-02-07 09:35:36,124 [37796980]   INFO - sdk.transport.SshRemoteSession - New ssh session created: vagrant@127.0.0.1:2222
2014-02-07  09:35:37,882 [37798738]   INFO - esdk.transport.JschExecProcess -  Executing ssh command: env "JETBRAINS_REMOTE_RUN"="1"  "RM_INFO"="RM-133.632" "LANG"="en_US.UTF-8"  "PATH"="/usr/local/bin:$PATH"  /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby -e "print RUBY_VERSION"  for vagrant@127.0.0.1:2222
2014-02-07 09:35:38,137 [37798993]   INFO  - esdk.transport.JschExecProcess - Executing ssh command: env  "JETBRAINS_REMOTE_RUN"="1" "RM_INFO"="RM-133.632" "LANG"="en_US.UTF-8"  "PATH"="/usr/local/bin:$PATH"  /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby -e  "print(defined?(RUBY_PATCHLEVEL) ? RUBY_PATCHLEVEL : 0)" for  vagrant@127.0.0.1:2222
2014-02-07 09:35:38,275 [37799131]   INFO -  yCreateRemoteInterpreterDialog - initializing Remote:ruby-1.9.3-p448:  1.9.3  (ssh://vagrant@127.0.0.1:2222/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby)  
2014-02-07 09:35:38,275 [37799131]   INFO - ruby.remote.RubyRemoteTransfer - Uploading helpers
2014-02-07  09:35:38,275 [37799131]   INFO - ugins.remotesdk.RemoteTransfer -  Uploading helpers to /home/vagrant/.rubymine_helpers/rb
2014-02-07  09:35:39,678 [37800534]   INFO - ugins.remotesdk.RemoteTransfer - Remote  helpers version is RM-133.632, local helpers version is RM-133.632
2014-02-07 09:35:39,678 [37800534]   INFO - ugins.remotesdk.RemoteTransfer - Helpers upload successfully completed
2014-02-07 09:35:39,702 [37800558]   INFO - ruby.remote.RubyRemoteTransfer - Helpers uploaded
2014-02-07  09:35:39,726 [37800582]   INFO - yCreateRemoteInterpreterDialog -  localGemsBinPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/2047682652,  remoteGemsBinPath=/usr/local/rvm/rubies/ruby-1.9.3-p448/bin
2014-02-07 09:35:39,726 [37800582]   INFO - ruby.remote.RubyRemoteTransfer - Updating gems' local copy
2014-02-07 09:35:39,821 [37800677]   INFO - ruby.remote.RubyRemoteTransfer - Gems copied.
2014-02-07  09:35:39,864 [37800720]   INFO - esdk.transport.JschExecProcess -  Executing ssh command: env "JETBRAINS_REMOTE_RUN"="1"  "RM_INFO"="RM-133.632" "LANG"="en_US.UTF-8"  "PATH"="/usr/local/bin:$PATH"  /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby -v for  vagrant@127.0.0.1:2222
2014-02-07 09:35:40,017 [37800873]   INFO -  esdk.transport.JschExecProcess - Executing ssh command: env  "JETBRAINS_REMOTE_RUN"="1" "RM_INFO"="RM-133.632" "LANG"="en_US.UTF-8"  "PATH"="/usr/local/bin:$PATH"  /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby -e  "print(defined?(RUBY_PATCHLEVEL) ? RUBY_PATCHLEVEL : 0)" for  vagrant@127.0.0.1:2222
2014-02-07 09:35:40,240 [37801096]   INFO -  s.ruby.ruby.run.AbstractRunner - Executing non-rvm sdk on system with  rvm installed thus GEM_PATH and GEM_HOME will be unset
2014-02-07  09:35:40,276 [37801132]   INFO - esdk.transport.JschExecProcess -  Executing ssh command: env "JETBRAINS_REMOTE_RUN"="1"  "RM_INFO"="RM-133.632" "LANG"="en_US.UTF-8"  "PATH"="/usr/local/rvm/rubies/ruby-1.9.3-p448/bin:/usr/local/bin:$PATH"  /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby  -C'/usr/local/rvm/rubies/ruby-1.9.3-p448/bin' -x  /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/gem environment gempath for  vagrant@127.0.0.1:2222
2014-02-07 09:35:40,492 [37801348]   INFO -  yCreateRemoteInterpreterDialog -  localPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/-1749636039/gems,  remotePath=/home/vagrant/.gem/ruby/1.9.1/gems
2014-02-07  09:35:40,492 [37801348]   INFO - yCreateRemoteInterpreterDialog -  localPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/-1749636039/specifications,  remotePath=/home/vagrant/.gem/ruby/1.9.1/specifications
2014-02-07  09:35:40,492 [37801348]   INFO - yCreateRemoteInterpreterDialog -  localPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/-1749636039/bundler,  remotePath=/home/vagrant/.gem/ruby/1.9.1/bundler
2014-02-07  09:35:40,492 [37801348]   INFO - yCreateRemoteInterpreterDialog -  localPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/-1857677612/gems,  remotePath=/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/gems
2014-02-07  09:35:40,492 [37801348]   INFO - yCreateRemoteInterpreterDialog -  localPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/-1857677612/specifications,  remotePath=/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/specifications
2014-02-07  09:35:40,492 [37801348]   INFO - yCreateRemoteInterpreterDialog -  localPath=/Users/guy/Library/Caches/RubyMine60/ruby_stubs/-302332565/-1857677612/bundler,  remotePath=/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/bundler
2014-02-07 09:35:40,492 [37801348]   INFO - ruby.remote.RubyRemoteTransfer - Updating gems' local copy
2014-02-07 09:35:41,901 [37802757]   INFO - ruby.remote.RubyRemoteTransfer - Gems copied.
2014-02-07  09:35:41,926 [37802782]   INFO - yCreateRemoteInterpreterDialog -  Remote:ruby-1.9.3-p448: 1.9.3  (ssh://vagrant@127.0.0.1:2222/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby)  initialized
2014-02-07 09:35:41,952 [37802808]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 5 ms
2014-02-07 09:35:41,952 [37802808]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update
2014-02-07 09:35:41,952 [37802808]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms


Do you think the 6.5 version is solving my issue or it's something different?


Thanks,
Guy



----------------------

I've just seen RVM is not supported in  the remote machine by Rubymine, I've tried rbenv(imploding rvm and installing rbenv) and it didn't work but I'll give some more tries....

Guy

Message was edited by: Guy

0
Comment actions Permalink

This is a different problem, and (unfortunately) rvm is not supported yet   
I hope I will have time to fix this in 6.5 but  I can not guaratee this :(

The tricky part with rbenv is that you need to point ruby binary which is under versions directory, do not use one under shims.
BTW what "no gems"? They are not listed in list of sdk gems or RubyMine complains that you do not have required gems installed?

Regards, Oleg.

0
Comment actions Permalink

Dang - I'm running into issues with rvm now as well. I wish I'd realized it wasn't going to work. :/

So is rbenv supported?

0
Comment actions Permalink

I actually was able to get debugging working with RVM after all.

I am using MRI (since debugging in Rubinius isn't yet supported)


I did two things:
1) Installed the ruby-debug-ide gem on the remote box myself by just doing this:
$ gem install ruby-debug-ide
Otherwise, RubyMine wants to install it using the --user-install option, which places the gem in an unlikely folder that isn't referenced by anything else, and then RubyMine is unable to find the executable for the gem on subsequent runs. So, do the above from an ssh prompt on the remote machine and DON'T let Rubymine install it for you.

2) I added the following to my ~/.zshenv file: (I use zsh/oh-my-zsh instead of bash, so add this to your bash equivalent)
The reason you have to add it to that file is that it's the only one that gets sourced when running a remote ssh command, which is what RubyMine uses to execute the remote debugging commands.
It might have been even easier if Rubymine let us modify the remote ssh commands a bit to add our own bits in first, but this is the next best thing:

#This file is here to make sure rvm is loaded for a particular ruby version if we're not in a login shell

#See http://rvm.io/rvm/basics Post install configuration for more details

#The next line will exit if we are in an interactive shell

#In other words, the stuff below it won't run unless we are trying to execute a single command over ssh

#a normal login or ssh session won't be affected

[ -z "$PS1" ] || return

export PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$PATH

export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

#This will set up the environment correctly

source $(rvm 2.1.0 do rvm env --path)


Of course, you have to change the last line if you're changing which Ruby you want to use for remote debugging, which is rather lame, however, the good news is that it works.

0
Comment actions Permalink

ah so thats the issue, well good luck fixing it - hope it makes it into 6.5!

0

Please sign in to leave a comment.