据我了解,gem 的文件夹结构应该有一个名为的文件夹lib
,并且在该文件夹内有一个<gem-name>.rb
文件。但是,当我使用jruby 1.6.8并bundle install
安装 jruby-openssl 时,我打开C:\jruby-1.6.8\lib\ruby\gems\1.8\gems\jruby-openssl-0.8.2
并没有看到 rb 文件,而是看到了更多如下所示的子文件夹:
jruby-openssl-0.8.2\
+---lib\
| +---1.8\
| | +---openssl\
| | +---openssl.rb
| +---1.9\
| | +---openssl\
| | +---openssl.rb
| +---ruby\
| | +---shared\
| +---shared\
| +---jopenssl\
| +---openssl\
| +---openssl.rb
+---test\
+---java\
jruby-openssl 不遵循标准 gem 文件夹结构是否有原因?具体来说,我似乎在使用gem 'jruby-openssl'
命令时遇到问题。gem
如果jruby-openssl 文件夹位于 LOAD_PATH 中,该命令是否应该正确找到并加载 gem?
错误详情:
这是出现在C:\apachetomcat632\logs\MyWebapp.log
--- Backtrace
LoadError: OpenSSL::Cipher requires the jruby-openssl gem
(root) at file:/C:/apachetomcat632/shared/lib/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/cipher.rb:8
MessageEncryptor at file:/C:/apachetomcat632/shared/lib/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/cipher.rb:24
ActiveSupport at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb:12
(root) at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb:4
require at org/jruby/RubyKernel.java:1062
require at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251
load_dependency at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236
require at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251
eager_autoload! at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb:43
each at org/jruby/RubyArray.java:1620
eager_autoload! at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies/autoload.rb:43
Bootstrap at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/application/bootstrap.rb:20
instance_exec at org/jruby/RubyKernel.java:2091
run at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/initializable.rb:30
run_initializers at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/initializable.rb:55
each at org/jruby/RubyArray.java:1620
run_initializers at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/initializable.rb:54
initialize! at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/application.rb:136
send at org/jruby/RubyKernel.java:2105
method_missing at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30
(root) at C:/apachetomcat632/webapps/Bank62P/WEB-INF/rails/config/environment.rb:5
require at org/jruby/RubyKernel.java:1062
load_environment at C:/apachetomcat632/webapps/Bank62P/WEB-INF/rails/config/environment.rb:23
load_environment at file:/C:/apachetomcat632/shared/lib/jruby-rack.jar!/jruby/rack/rails_booter.rb:65
(root) at <script>:1
这是整个 cipher.rb 文件:
require 'rubygems'
# try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present
begin
gem 'jruby-openssl'
require 'openssl.rb'
rescue Gem::LoadError => e
raise LoadError.new("OpenSSL::Cipher requires the jruby-openssl gem")
end