Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with require gem, when passing git-repo to gem in Gemfile

I haven't done this in the past, so may be I am missing something here.

I changed the Gem files for 'ruby-git' locally and it worked fine. I forked a gem and made same changes to it, in my Github repo.

While building the Sinatra app to push it to Heroku, I changed the Gemfile as follows:

gem 'git', :git => "git://github.com/silverSpoon/ruby-git.git"`  

When I run bundle install, I get

Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using rugged 0.21.0
Using sinatra 1.4.5
Using git 1.2.8 from git://github.com/silverSpoon/ruby-git.git (at master)
Your bundle is complete!
  • But, when I say ⇒ gem list git, it doesn't show the gem as installed.
  • When I run, ⇒ bundle show git, it shows the path where the gem repo was installed -
    /Users/jatinganhotra/.rvm/gems/ruby-2.1.3@527website/bundler/gems/ruby-git-c7fb35af1a99
  • When I run my app, or run irb and do a 2.1.3 :001 > require 'git'
    it get the following error -
    LoadError: cannot load such file -- git

Am I missing something silly here?

like image 261
Jatin Ganhotra Avatar asked Oct 17 '25 14:10

Jatin Ganhotra


1 Answers

Gems installed by Bundler through git are not handled the same way as normal gems:

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.

In order to use the gem you need to do it through Bundler. Either use bundle exec when launching IRB or your app, or use Bundler.setup from within your code.

$ bundle exec irb
> require 'git' # should work ok

or:

$ irb
> require 'bundler/setup'
> require 'git' # should also work
like image 153
matt Avatar answered Oct 19 '25 12:10

matt