What is the simplest way to download a gem without installing rubygems?

10

3

I would like to download a gem without installing all the required gems for a given gem.

Specifically for the Rails 3 gem. It has a lot of dependencies, and I need to install it on a closed server which currently has no ruby/rake/rails software.

Any clues would be great as clicking through rubygems.org is tedious.

okay, let me clarify this a bit. What I would like is for this to work:

gem install rails --download-only

which would solve my problems as then I could burn the resulting gem's onto a disc and move them over to my server which doesn't have Internet access.

Daniel

Posted 2011-08-19T17:47:57.297

Reputation: 932

Not sure that this is possible. That is why they are called dependencies. They depend on other things that you have to have to work. – soandos – 2011-08-19T18:45:11.410

Answers

18

To download a single gem use (using loudmouth gem as an example):

gem fetch loudmouth
Fetching: loudmouth-0.2.4.gem (100%)
Downloaded loudmouth-0.2.4

to download all gems that your Rails 3 app depends on run:

bundle package

This will download all gems (and their dependencies) and place them into vendor/cache (without installing them).

You can then burn all the gems in vendor/cache to a CD and physically bring it to the other server without net access.

pglombardo

Posted 2011-08-19T17:47:57.297

Reputation: 306

2You need to specify --no-install to bundle package to skip installation. – xoryves – 2017-09-21T08:04:44.277

A bit too late to use, but this is the answer I was looking for. Thanks for posting it. – Daniel – 2012-10-25T01:17:15.977

2

Well, I hate to answer my own question but I think this is the most likely to be the solution for my question.

- find network enabled machine
- install rails and all needed gems using RubyGems.
- tar/zip /usr/lib[64]/ruby/gem/1.9.1/cache/*.gem
- transport tar file to non-networked computer.

The location of those gem cached files is very useful. If I had numerous gem's on my networked machine and didn't want to transport all the gems I would have used

> bundle list

to show the application specific gems needed.

-daniel

Daniel

Posted 2011-08-19T17:47:57.297

Reputation: 932

2

I would create a local RubyGems server with all the gems required for the application, including Rails and its dependencies.

Basic documentation here:

This blog post shows how to set up an internal server that you can send Gems to for automatic indexing:

jtimberman

Posted 2011-08-19T17:47:57.297

Reputation: 20 109

0

Unfortunately you cannot get around the dependency issue. They are needed for a reason; Trying to install Rails without needed dependencies is going to result in a lot of issues, if Rails even runs at all.

You didn't specify exactly what you meant by closed. If you mean closed as in you cannot install systemwide software, have a look at RVM, which is software that will allow you to create a self-contained Ruby environment. You might also be able to get away with setting this up on another server and moving it over if the server has no connection to the internet. Have a look at it and see if this helps you out.

8BitsOfGeek

Posted 2011-08-19T17:47:57.297

Reputation: 1 744

If I can't manually download the gem's then I'll probably have to use this method: I'll use a linux VM and create a rails complete install package. – Daniel – 2011-08-19T20:30:30.610