0

I need to install gem form git repository. repository contains .gemspec file. In my gem file i have following code:

gem 'echo_server', :git => 'http://127.0.0.1/org/echo_server.git'

When i am running bundle install gems are installer in .bundeler and not showing in gem list.

my question is: How the gem will be available in system, so that i can use in require ?

There are some similar SOQ but it does't help me.

Community
  • 1
  • 1
suvankar
  • 1,548
  • 1
  • 20
  • 28

1 Answers1

2

It is not showing up when you type gem list because it is not being installed like a regular gem. You can require it like you would any other library because Bundler knows about it and will set it up for you. You should see it in your $LOAD_PATH:

$LOAD_PATH.grep(/nameofgem/)

See the Bundler documentation on this for more information.

If instead you want to install it as a regular gem from the Git repository, you can clone the repository and then build and install the generated gem. For example:

gem build echo_server.gemspec
gem install echo_server-X.Y.Z.gem

There is also specific_install.

blom
  • 3,072
  • 1
  • 15
  • 5
  • Yes, if i use `gem bild` then `bundle install` then it's working fine. But some how i need to automate it, by using only `bundle install`. Is there any way to achieve it? there is nothing added in ruby $LOAD_PATH – suvankar Mar 28 '14 at 11:38
  • 1
    As far as I am aware, Bundler can't be used to install a gem from a Git repository to the gem path like `gem install` would. You can see where Bundler installed the gem with `bundle show echo_server`. I also updated my answer to link to [specific_install](https://github.com/rdp/specific_install). – blom Mar 28 '14 at 15:27
  • if i do 'bundle install' gem is installed in $BUNDLER_PATH. How could i use it in irb? irb> require 'echo_server' #=> LoadError: cannot load such file. because irb looking for it in ruby home, but bundler installed it in bundler home. – suvankar Mar 31 '14 at 11:14
  • Bundler needs to be loaded. In the same directory as your Gemfiles, try `bundle console` instead of `irb`. You can also do `require 'bundler'`, `Bundler.setup`, and `require 'echo_server'`, in that order. See [the Bundler documentation](http://bundler.io/) for more information. – blom Apr 01 '14 at 06:19