简体   繁体   English

Rails不会从供应商/宝石加载宝石

[英]Rails does not load gems from vendor/gems

I have strange old buggy project on Rails 2. 我在Rails 2上有一个奇怪的旧越野车项目。
It have gem's dependencies in config/environment.rb like 它在config / environment.rb中具有gem的依赖项,例如

config.gem "andand"
config.gem "json"
config.gem "chronic"
config.gem "mini_fb"

all those gems are located in vendor/gems/ 所有这些宝石都位于供应商/宝石/

andand-1.3.3/
chronic-0.6.7/
json-1.7.3/
mini_fb-1.1.7/
rbet-1.0.3/
redis-3.0.1/
responsys_client-0.0.1/

but when i start unicorn server with this app it always complain that it can't find this gems. 但是,当我使用此应用程序启动独角兽服务器时,它总是抱怨找不到该宝石。 Why? 为什么?

UPDATE UPDATE

After building and installing gem from vendor/gems rails still complain about it. 从供应商/宝石制造商安装宝石后,rails仍然会抱怨它。

I have tweake mini_fb gem into custom mini_fb_custom gem. 我将mini_fb宝石调整为自定义mini_fb_custom宝石。 Changed all references in gemspec and other files from mini_fb to mini_fb_my, installed it and it is shown in gem list as mini_fb_my. 将gemspec和其他文件中的所有引用从mini_fb更改为mini_fb_my,进行安装,并在gem list为mini_fb_my。 But it fails to load from config/environment.rb and complains that 但是它无法从config / environment.rb加载,并抱怨说

Missing these required gems:
  mini_fb_my  >= 0

maybe i should rename lib/mini_fb.rb to lib/mini_fb_my.rb i'll check it. 也许我应该将lib / mini_fb.rb重命名为lib / mini_fb_my.rb,我会进行检查。

UPDATE 2 更新2
Yes, renaming files rocks! 是的,重命名文件很麻烦!

You still need to install them from those folders, or unicorn will not know where to look for them. 您仍然需要从这些文件夹中安装它们,否则独角兽将不知道在哪里寻找它们。

Just install the gems from that directory and unicorn should pick them up. 只需从该目录中安装gem,麒麟应将其拾取。

UPDATE UPDATE

You can install your gems locally with this command 您可以使用此命令在本地安装gem

gem install --local vendor/gems/gem/gem-name.gem

On more recent versions of rails you just specify path on the Gemfile 在最新版本的rails上,您只需在Gemfile上指定路径

gem "gem-name", path: "path/to/gem"

My advice: replace the obsolete gem configuration with bundler (it works fine with rails 2, there should be a tutorial for rails 2 available on their website). 我的建议:用捆绑器替换过时的gem配置(它可以在rails 2上正常工作,应该在其网站上提供rails 2的教程)。

Configuration through gem command, freezing gems, etc. is just pain in the a** and it seemed kinda buggy to me when I'd used it (long time ago). 通过gem命令配置,冻结gem等只是a **中的痛苦,而当我使用它(很久以前)时,对我来说似乎有点麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM