Rails Bundler on windows refuses to install hprico

2019-02-28 07:25发布

问题:

Upgraded to rails 3, and using Bundler for gems, in a mixed platform development group. I am on Windows. When I run Bundle Install it completes succesfully but will not install hpricot. The hpricot line is:

gem "hpricot", "0.8.3", :platform => :mswin

also tried

gem "hpricot", :platform => :mswin

Both complete fine but when I try to do a "bundle show hpricot" I get:

Could not find gem 'hpricot' in the current bundle.

If I do a run a rails console and try "require 'hpricot'" I get:

LoadError: no such file to load -- hpricot

I have manually installed hpricot as well, and still get the above error. This worked fine before moving to rails 3.

回答1:

Try this in console and then do bundle install, it will work:

gem install hpricot --platform=mswin32


回答2:

It may be that you are using a version of ruby that was built with MinGW in which case your platform will be 'mingw' rather than 'mswin'. Try changing your Gemfile line to the following:

gem "hpricot", "0.8.3", :platform => :mingw

And if you have other developers that are using the current setup and don't wan to break it for them, change it to this:

gem "hpricot", "0.8.3", :platforms => [:mswin, :mingw]