Bundler: installing a specific .gem file

2019-07-22 11:03发布

问题:

Is there a way to tell Bundler to install a particular .gem file I have lying around?

I have a compiled version of ParseTree that I must use (damn you, Windows!), but didn't want to expand the gem file in order to add a :path => '...' attribute to the 'gem' requirement.

回答1:

You could also package your gems with bundle package, which puts all of your gems in the vendor/cache directory of your project. If needed, overwrite ParseTree with your precompiled gem in in that directory. Then, when you set up your project on another machine, run bundle install --local and it will only install gems that you've packaged.



回答2:

Instead of setting up your own gem-server, I was able to solve this by writing the following in my Gemfile (the explicit version is crucial):

gem 'libv8', '3.11.8.3mytest', :path => '../libv8/pkg'

And the ../libv8/pkg folder contains only the binary packaged gem libv8-3.11.8.3mytest-x86_64-linux.gem.

Hope this helps.



回答3:

I don't think you can. As far as I know, you need to gem unpack the .gem into something like vendor/ and set the :path option.



回答4:

Can't you point the gem declaration to your ParseTree fork at Github?



回答5:

I figured it out -- thanks to everyone who responded! :)

The trick was to set up a local gem server (with, uh, "gem server") and change my Gemfile's source to point to http://localhost:8808 instead of http://rubygems.org.

This means bundler will grab all the gems from the current installed gem set (which happens to be fine for my case) and then the compiled libs just work.