Ruby - Loading gems form non-default directory -
Ruby - Loading gems form non-default directory -
i'm trying load rubygems non-default directory, default (please right me here, if i'm wrong) specified in gem.path
array. i've managed load gem i've got installed in non-default directory (which 'rubyzip'
) in few cases...
i'm using jruby 1.7.12 , ruby 1.9.3.
here test results:
loading gem "e:/rb/gems_" directory:
gem.path => ["c:/users/default/.gem/jruby/1.9", "file:/e:/rb/libraries/jruby.jar!/meta-inf/jruby.home/lib/ruby/gems/shared"] gem.path[0] = "e:/rb/gems_" => "e:/rb/gems_" require 'zip' => true
in test above, replaced default user-related gem path "e:/rb/gems_" directory, , worked fine.
gem.path.clear => [] gem.path.unshift "e:/rb/gems_" => ["e:/rb/gems_"] require 'zip' => true
again, though cleared whole array , replaced own entry, worked fine.
loading gem "e:/rb/gems" directory (no underscore now. tested possibility wrong naming):
gem.path.clear => [] gem.path.unshift "e:/rb/gems" => ["e:/rb/gems"] require 'zip' => true
this test completed successfully.
, here comes lastly test:
gem.path.clear => [] require 'zip' loaderror: no such file load -- zip org/jruby/rubykernel.java:1065:in `require' file:/e:/rb/libraries/jruby.jar!/meta-inf/jruby.home/lib/ruby/share d/rubygems/core_ext/kernel_require.rb:55:in `require' (irb):4:in `evaluate' org/jruby/rubykernel.java:1101:in `eval' org/jruby/rubykernel.java:1501:in `loop' org/jruby/rubykernel.java:1264:in `catch' org/jruby/rubykernel.java:1264:in `catch' file:/e:/rb/libraries/jruby.jar!/meta-inf/jruby.home/bin/jirb:13:in `(root)' org/jruby/rubykernel.java:1081:in `load' file:/e:/rb/libraries/jruby.jar!/jruby/commands.rb:1:in `(root)' jirb:1:in `(root)' gem.path => [] gem.path.clear.unshift "e:/rb/gems" => ["e:/rb/gems"] require 'zip' loaderror: no such file load -- zip org/jruby/rubykernel.java:1065:in `require' file:/e:/rb/libraries/jruby.jar!/meta-inf/jruby.home/lib/ruby/share d/rubygems/core_ext/kernel_require.rb:55:in `require' (irb):7:in `evaluate' org/jruby/rubykernel.java:1101:in `eval' org/jruby/rubykernel.java:1501:in `loop' org/jruby/rubykernel.java:1264:in `catch' org/jruby/rubykernel.java:1264:in `catch' file:/e:/rb/libraries/jruby.jar!/meta-inf/jruby.home/bin/jirb:13:in `(root)' org/jruby/rubykernel.java:1081:in `load' file:/e:/rb/libraries/jruby.jar!/jruby/commands.rb:1:in `(root)' jirb:1:in `(root)' gem.path => ["e:/rb/gems"]
and here comes "interesting" part. tried load 'zip'
file when there no entry in gem.path
array, failed, of course of study more fine result. however, when filled array 1 entry pointing non-default directory rubyzip gem, failed again!
my question is: why sec atemp of loading rubygem failed? there i'm overlooking? approach of loading gems non-default directory right, or there improve one?
ruby gem rubygems jruby
Comments
Post a Comment