Can't find plugin from RubyMine

When I run script/server from a shell prompt, the server starts without error.  If I start the server from RubyMine, I get the following (truncated):
L:\bin\ruby.exe -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) K:/Code/dialectic/script/server default -p 3000 -b 127.0.0.1 -e development
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://127.0.0.1:3000
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- acts_as_state_machine (MissingSourceFile)
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from K:/Code/dialectic/vendor/plugins/acts_as_state_machine/init.rb:1:in `evaluate_init_rb'
    from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/plugin.rb:146:in `evaluate_init_rb'

What do I need to change so that RubyMine can start my server AND find the plugins?

11 comments

I'm using cygwin's Ruby and the Windows RubyMine, and the problem is related to this combination.  Here's a truncated dump of $LOAD_PATH when run via ./script/server:
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.2/lib/action_mailer/vendor/tmail-1.2.3,/cygdrive/k/code/dialectic/app/controllers/,/cygdrive/k/code/dialectic/app

and here is the same truncated path when run from RubyMine:
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.2/lib/action_mailer/vendor/tmail-1.2.3,K:/Code/dialectic/app/controllers/,K:/Code/dialectic/app

I found a hack that will work-around the issue.  In the run configuration, I set the sole argument to ruby to be "/cygdrive/k/code/dialectic/script/serverk", and then in serverk I put
     system  File.dirname(__FILE__) + '/server'

I'm starting RubyMine from a Cygwin bash prompt.  I'm not where the patch are getting switched to Windows paths.  I *suspect* that Cygwin's ruby uses "/cygdrive/k" when it is run from a Cygwin process, and "K:/" when it is run from a Windows process (i.e. RubyMine).   RubyMine itself works pretty well with the Cygwin ruby; it just runs into trouble starting the server.  One possible work around would be to let the user specify the command to start the ruby interpreter.   Then I could tell it that it should run ruby via a bash script.

Is there a better way to start the server than my hack?  Is there a way to specify the command to start the ruby interpreter (just the L:\bin\ruby.exe part).

0

Here's a better hack:  In the run configuration, set the Ruby arguments to:
-e "STDOUT.sync=true;STDERR.sync=true;RAILS_ROOT='/cygdrive/k/code/dialectic';ARGV.shift;load('/cygdrive/k/code/dialectic/script/server')"

The source of the problem is this line:
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)

inside boot.rb.  When run from RubyMine, it uses K:/ paths, because RubyMine invokes the server using K:/code/dialectic/script/server.  If script/server is invoked as /cygdrive/k/code/dialectic/script/server, File.dirname returns a cygwin-style path, and if it is invoked as K:/code/code/dialectic/script/server, then File.dirname returns a Windows-style path.

IF it is possible for RubyMine to detect that it is using Cygwin's ruby, it would be a nice enhancement to invoke the server using a cygwin-style path.

0

Hello Kevin,

Thanks for the issue, I've filled a bug: http://www.jetbrains.net/jira/browse/RUBY-4159
Feel free to vote, comment and track progress.

Regards,
Oleg

0

Hi Kevin,

Thank you for the issue. I suppose this problem also may affect other situations when RubyMine passes file/folder paths as arguments to ruby interpreter. Probably RM should automatically replace all *$DriveLetter&:/* to */cygdrive/$DriveLetter$/* in case if running under Windows with cygwin ruby sdk.

0

I've got it 99% solved by configuration.  I created cygpath.rb, containing:

def cygpath(s)
  `/bin/cygpath #{s}`.chomp
end
Then I set the "Ruby arguments" in the configuration to:

-e "STDOUT.sync=true;STDERR.sync=true;RAILS_ROOT=Dir.pwd.chomp;require 'cygpath';load(cygpath($0=ARGV.shift))"

This successfully starts the server, and it will work for all of my projects.

I've done something similar for each of the configurations and for all of the default configurations.  However, when I press "control-alt-g, i" and type the name of a new migration ("delete_me_soon"), and click OK, the command line is:

L:\bin\ruby.exe -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) K:/Code/projectname/script/generate migration delete_me_soon

Where do I set the ruby arguments for generating a new migration?

0

The arguments for generate are hard-coded in RubyUtil.class, which is in C:\Program Files\JetBrains\RubyMine 1.1\lib\rubymine.jar.  :-(
However, by patching RubyUtil.class, I was able to replace "STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" with "require        'kpkinit';load(cygpath($0=ARGV.shift)", and I can now run my generator by creating kpkinit.rb containing:

STDOUT.sync=true;STDERR.sync=true;RAILS_ROOT=Dir.pwd.chomp;
def cygpath(s)
  `/bin/cygpath #{s}`.chomp
end

It would be nice if there were a way to override the ruby arguments without patching a class file inside a jar.  ;-)

0

It would be nice if there were a way to override the ruby arguments without patching a class file inside a jar.  ;-)

I've created an issue - http://www.jetbrains.net/jira/browse/RUBY-4286. Actually patching RM's files is a bad way, because our comming automatic update feature will not work/will work incorrectly with patched RubyMine.

Kevin, thank you for tip related to cygwin.

0

UPDATE: The hack still works for RubyMine 1.1.1.

I'm looking forward to 1.5, when this will be configurable.
Thanks for improving it!

0

Kevin,

Specially for you I've added ability to configure that pass without patching rubymine.jar. See my comment to http://www.jetbrains.net/jira/browse/RUBY-4286. I also doesn't recommend you to patch RubyMine files because auto update feature wont work well in this case.

0

Do you have a list of all these configuration options? I'd like to pass in cygpath for my server instance and debugging as well.

0

All available options are mentioned in http://youtrack.jetbrains.net/issue/RUBY-4286. If you need something more please file an issue at http://youtrack.jetbrains.net/issues/ruby.

I'd like to pass in cygpath for my server instance and debugging as well.

What should I do to pass it? Please provide more details.

0

Please sign in to leave a comment.