bundle install fails but gem install succeeds

567 views Asked by At

I have often seen that bundle install will try to build a gem but gem install fetches the same gem from remote repository. I thought bundler would also try to fetch the gems. Can anyone explain the difference? For example, if my Gemfile lists libv8, bundle install fails with the following error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 
....
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.

But, gem install succeeds by just fetching it. man bundle-install has this to say:

If this is the first time you run bundle install (and a Gemfile.lock does not exist), bundler will fetch all remote sources, resolve dependencies and install all needed gems.

Why does bundle install decide to build the gem while gem install just installs it? Also, it may build for some version but just install it for some other version of the same gem? For example, thrift-0.9.0.1.patched is built but thrift-0.9.2.0 is installed on my machine. Why the difference?

0

There are 0 answers