问题
I am a Ruby noob (rube?) and am having trouble configuring my environment to get rake
to build something with a Java dependency.
I run
$ PATH=/tmp/jruby-dodge:"$PATH" rake
and get
/opt/local/bin/ruby -S rspec spec/contextual_spec.rb /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- java (LoadError) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /Users/msamuel/work/igrigorik/contextual/lib/contextual/contextual.rb:1 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /Users/msamuel/work/igrigorik/contextual/lib/contextual.rb:2 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /Users/msamuel/work/igrigorik/contextual/spec/contextual_spec.rb:1 from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `autorun' from /opt/local/bin/rspec:19 rake aborted! /opt/local/bin/ruby -S rspec spec/contextual_spec.rb failed Tasks: TOP => default => spec (See full trace by running task with --trace)
The PATH=/tmp/jruby-dodge:...
makes sure that which ruby
actually resolves to a symlink to /opt/local/bin/jruby
.
Is "no such file to load -- java" related to jruby at all? java -version
emits java version "1.6.0_29"
so I don't think there is a failure to start up a JVM.
When using rake
to build something with Java dependencies for use under jruby, does it matter whether rake
is running under jruby or ruby? If so, how do I specify that?
回答1:
It looks like rvm
lets me juggle multiple rubies.
Installing RVM explains how to install it.
rvm install jruby
makes sure rvm
knows about jruby.
rvm use jruby
updates the environment so that ruby
means jruby
.
Gems seem to be installed per-flavor of ruby.
来源:https://stackoverflow.com/questions/9203081/rake-no-such-file-to-load-java-even-when-which-ruby-jruby