Installing a gem from Github with Bundler

2020-02-23 06:44发布

问题:

I am trying to use the instructions here to install a pre-released version of a gem with bundler.

The "bundle install" output lists the gem as getting installed, but "gem list" fails to find it.

My Gemfile:

source :gemcutter

gem 'sinatra', '1.1.0', :git => 'http://github.com/sinatra/sinatra.git'
gem 'RedCloth', '4.2.3'

Here is a gist with the rest of my sample code.

Has anyone gotten this scenario to work?

NOTE: I am also using RVM (on OS X). bundle show does list the gem (and dependencies) as existing, but I am not able to properly resolve them.

Thanks.

回答1:

I would look at the load paths, and further debug from there, example:

...(master) $ irb
irb(main):001:0> $LOAD_PATH.count
=> 8
irb(main):004:0> require 'bundler/setup'
=> true
irb(main):005:0> $LOAD_PATH.count
=> 112
irb(main):006:0> 

Bundler configures the load path for you, this means not all the gems are included on your load path by default.

Additionally, from the bundler git help:

Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup.

Best regards, hope this helps

ED



回答2:

Bundler might have installed it locally to your app. This could vary wildly, depending on OS and whether you are using RVM.

What is the output of bundle show sinatra?

In my case, sinatra was installed here:

/home/marshall/.rvm/gems/ruby-1.8.7-p302@3846859/bundler/gems/sinatra-9cfa74a7f352

Sinatra doesn't show in the gems list, but the server launches correctly if I execute rackup.



回答3:

Gems installed via bundler on Engine Yard go to a different folder to isolate them.

it's usually /data/APP_NAME/shared/bundled_gems

To be sure, check your .bundle/config file on your APP folder at Engine Yard



回答4:

It looks like there is an issue using Shotgun and Bundler (git repositories only).

If I use rackup to start up my app, all is well. I am going to investigate a little more and then file a bug with one (or both) of the projects.