宝石定制
我向 geokit gem 添加了一些缓存功能,并使用 gemcutter 创建了一个副本“badnaam-geokit”。唯一的变化是在 Geocoders.rb 中,如果我只是在本地修改它,它就可以正常工作。
然而,在我将它发布到 rubygems 并安装它并在我的environment.rb(config.gem“badnaam-geokit”)文件中要求它作为“badnaam-geokit”之后,我得到了一个令人讨厌的结果。
有什么想法吗?
这是我在 github 上的分支
http://github.com/badnaam/geokit-gem
这是宝石。 http://rubygems.org/gems/badnaam-geokit
no such file to load -- badnaam-geokit
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:208:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems'
I added some caching functionality to the geokit gem and used gemcutter to create a copy 'badnaam-geokit'. The only changed are in Geocoders.rb which works fine if I just modify it locally.
However, after I published it to rubygems and installed it and require it as 'badnaam-geokit' in my environment.rb (config.gem "badnaam-geokit") file I get a nasty.
Any ideas?
Here is the my fork on github
http://github.com/badnaam/geokit-gem
and here is the gem.
http://rubygems.org/gems/badnaam-geokit
no such file to load -- badnaam-geokit
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:208:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然您的 gem 已更改名称,但库名称并未更改。您的 config.gem 行告诉 Rails 加载 gem,然后 require 'badnaam-geokit' ,但您的 gem 中没有该名称的文件。
要修复此问题,请使用
config.gem
的:lib
选项:此外,不鼓励将 gems 推送到 Rubygems 进行此类更改。相反,我建议您将 Rails 项目切换为 使用 Bundler (其中 使用 Bundler)。 com/rails23.html" rel="nofollow noreferrer">与 Rails 2.3.5 配合良好),然后使用
:git
选项直接从 Github 分支加载 gem。While your gem has changed names, the library name has not changed. Your
config.gem
line is telling Rails to load the gem and thenrequire 'badnaam-geokit'
but there's no file in your gem by that name.The fix this, use the
:lib
option toconfig.gem
:Furthermore, pushing gems to Rubygems for changes like this is not encouraged. I would instead suggest you switch your Rails project to use Bundler (which works great with Rails 2.3.5) and then use the
:git
option to load the gem directly from your Github fork.我使用了 :lib 选项。
这就是
config.gem "badnaam-geokit", :lib => 的工作原理“地质套件”
I used the :lib option.
So this is what worked
config.gem "badnaam-geokit", :lib => "geokit"