Rails: gem.config & rake gems:install — no such file to load

情到浓时终转凉″ 提交于 2019-12-11 07:01:53

问题


I'm trying to use config/environment.rb to install a ruby gem dependency (because I don't have sudo access to our server; ergo, can't just call gem install hpricot).

I've tried including sundry arguments (:version, :source, :lib) but I still get rake aborted! no such file to load -- hpricot

Update: It turns out that when I remove the plugin which requires hpricot, then I can execute rake gems:install successfully. But that's not very helpful. It means that if I ever move my app, I run into a problem of being unable to rake its gems (because I will have reinstalled the plugin and added features that depend on it).

How is this supposed to work?

Sys: WinXP, Ruby 1.8.7, Rails 2.3.5


回答1:


rake gems:install has been deprecated because it never really worked. You can imagine having a gem installer with dependencies to the very gems it's trying to install is a bad idea.

It's advisable to use bundler instead if that's an option.

Bundler allows you to install gems to any destination you want, something specifically intended to side-step the whole "requires sudo" problem you describe. It's often as easy as this:

bundle install --path ~/my_gems/

You can make your Rails 2.3.x application use Bundler by following a few simple steps and from there your life will be a lot easier.




回答2:


Rails is trying to load the gem before executing the rake task. This is a known issue with rails 2.x. The only solution I know of is to switch to using bundler to manage gems or manage then manually.

Bundler can be used with rails 2 but it requires some modifications to your application and deployment scripts. This is a good place to start: http://gembundler.com/rails23.html



来源:https://stackoverflow.com/questions/7067457/rails-gem-config-rake-gemsinstall-no-such-file-to-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!