简化的问题是ruby’require'(和rails)无法找到我的应用程序所需的所有宝石.并且似乎宝石需要找不到具有与* .rb不同的宝石名称.例如,“require’sass”’找到sass.rb.但是“require’therubyracer’”无法在lib中找到v8.rb.没有名为’therubyracer.rb’的文件.相同
与’therubyrhino’ – 没有’therubyrhino.rb’但是在lib中有一个’rhino.rb’.
即使这些gem在我的Gemfile中,Bundle install也不会抛出错误.
这是一个例子:
首先,要演示安装的gem:
>locate 'rhino.rb' /usr/local/lib/ruby/gems/1.9.1/gems/therubyrhino-1.73.1/lib/rhino.rb /usr/local/lib/ruby/gems/1.9.1/gems/gems/therubyrhino-1.73.1/lib/rhino.rb
即使安装了“therubyrhino”,并且在路径和捆绑工作中,“宝石哪个”找不到它.这个宝石就在
与’sass’相同的路径,在下面,它可以找到.这是错误:
gem which 'therubyrhino' ERROR: Can't find ruby library file or shared library therubyrhino
请注意,gem可以在gem中找到rhino.rb文件,因此路径必须正常工作.
>gem which rhino /usr/local/lib/ruby/gems/1.9.1/gems/therubyrhino-1.73.1/lib/rhino.rb
要求不喜欢rhino.rb:
ruby -rubygems -e 'require "rhino"' /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in ` require': no such file to load -- java (LoadError)
并且它无法通过名称找到宝石.
ruby -rubygems -e 'require "therubyrhino"' /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in ` require': no such file to load -- therubyrhino (LoadError) from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in ` require'
但正如我所提到的,我的Gemfile中有’therubyrhino’,Bundle安装有效.
这是我的宝石路径,我手动设置测试:
>export GEM_PATH=/usr/local/lib/ruby/gems/1.9.1:/usr/local/lib/ruby/gems/1.9.1/gems:/usr/local/lib/ruby/gems/1.9.1/gems/gem>gem env ...RubyGems Environment: - RUBYGEMS VERSION: 1.8.15 - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i686-linux] - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1 - RUBY EXECUtable: /usr/local/bin/ruby - EXECUtable DIRECTORY: /usr/local/bin - RUBYGEMS PLATFORMS: - ruby - x86-linux - GEM PATHS: - /usr/local/lib/ruby/gems/1.9.1 - /usr/local/lib/ruby/gems/1.9.1/gems - /usr/local/lib/ruby/gems/1.9.1/gems/gem - GEM CONfigURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://rubygems.org/
最后,这是一个生活很美好并需要工作的案例.一切都很好,并且gem name = lib name(… / sass / lib / sass.rb)的前缀.首先我们可以看到安装了sass gem:
>locate sass.rb /usr/local/lib/ruby/gems/1.9.1/gems/sass-3.1.14/lib/sass.rb /usr/local/lib/ruby/gems/1.9.1/gems/haml-3.1.4/vendor/sass/lib/sass.rb /usr/local/lib/ruby/gems/1.9.1/gems/haml-3.1.4/lib/sass.rb
宝石可以找到吗?是.
>gem which sass /usr/local/lib/ruby/gems/1.9.1/gems/haml-3.1.4/lib/sass.rb
ruby’需要’工作吗?是.
>ruby -rubygems -e 'require "sass"' (no error)
谢谢你的帮助.
解决方法 在能够要求之前,您必须使用gem命令加载gem.例如 :$irb1.9.3p0 :001 > gem 'therubyracer' => true 1.9.3p0 :002 > require 'v8' => true总结
以上是内存溢出为你收集整理的ruby-on-rails – Ruby Gems Path Weirdness全部内容,希望文章能够帮你解决ruby-on-rails – Ruby Gems Path Weirdness所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)