Search code examples
rubyrmagickrubymine

Can't launch using from RubyMine


I am having problem with RubyMine 4.0.1 on Windows 7. Every time i run ruby script from RubyMine which contains the only line

require 'rmagick'

I recieve

LoadError: 126: The specified module could not be found.   - C:/Ruby193/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/RMagick2.so
    from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
    from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
    from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/RMagick.rb:11:in `<top (required)>'
    from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
    from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
    from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from (irb):1
    from C:/Ruby193/bin/irb:12:in `<main>'

But when I run the same script from cmd, everything works just fine. I tried to change run configurations, adjusting environment variables, but nothing seemed to work.


Solution

  • It turned out that the problem was caused by updated system PATH environment not passed to RubyMine process. New PATH value was passed only after machine reboot (logout should also help).

    To debug such kind of issues on Windows system it's handy to use such tools like Process Explorer (allows to verify the actual process environment) and Rapid Environment Editor (allows to easily edit environment and detects errors in paths).

    Usually it's enough to restart the process to get environment variable changes into account, but in case some custom launcher (explorer) is used, the new process may still inherit its environment and it's required to restart the parent process as well, or logout/reboot.


    In this particular case the user has updated system PATH environment to include the ImageMagick directory that contains the DLLs required for RMagick2.so, however RubyMine process didn't get the new value of PATH after IDE restart and was still using the value without ImageMagick DLLs. After system reboot RubyMine started to use the new PATH value and rmagick gem was able to find all the dependencies.