If I download a .gem file to a folder in my computer, can I install it later using gem install
?

- 158,662
- 42
- 215
- 303

- 74,396
- 19
- 43
- 46
-
This post is related to http://stackoverflow.com/questions/1864618/install-gem-locally – Jaider Jul 15 '14 at 20:35
9 Answers
Also, you can use gem install --local path_to_gem/filename.gem
This will skip the usual gem repository scan that happens when you leave off --local
.
You can find other magic with gem install --help
.
-
I download a gem such as rubygems in zip format. So there is no .gem file here. How do I install this from local ? Thank you. – Erran Morad Jan 10 '15 at 00:15
-
3@BoratSagdiyev, a zip file is not a gem. Like most zip files, you need to unzip it before you can do much with it. If it contains a gem, then you can use gem install on the extracted .gem file. I don't remember the internals of the gem format; it's possible it may just be a zip file with a special header, but rubygems doesn't recognize zip files as such. – JasonTrue Jan 10 '15 at 03:50
Yup, when you do gem install
, it will search the current directory first, so if your .gem file is there, it will pick it up. I found it on the gem reference, which you may find handy as well:
gem install will install the named gem. It will attempt a local installation (i.e. a .gem file in the current directory), and if that fails, it will attempt to download and install the most recent version of the gem you want.

- 2,594
- 1
- 22
- 31

- 87,773
- 37
- 126
- 127
-
2
-
3
-
4I have a `Gemfile` but not a `.gem` file. So what is this `.gem` file? What should it contain? — Wait – I see. You mean an `gem-name.gem` file. Remember that on unix it's pretty normal to have file starting with a '.' so it's better to spell it out. – Martin Mar 22 '20 at 08:15
-
I can confirm from the future of 2020, the link works for me. In case it doesn't work in the distant future, here's the Archive.org [April 19th, 2020 snapshot](https://web.archive.org/web/20200419034615/https://guides.rubygems.org/command-reference/#gem-install) – Jed Burke May 30 '20 at 10:23
-
1"I have a Gemfile but not a .gem file" - Run `gem build` to generate a *.gem file from Gemfile (I'm a ruby noob, this worked for me!) – ptim Sep 06 '21 at 23:58
you can also use the full filename to your gem file:
gem install /full/path/to/your.gem
this works as well -- it's probably the easiest way

- 25,663
- 9
- 82
- 87
If you create your gems with bundler:
# do this in the proper directory
bundle gem foobar
You can install them with rake after they are written:
# cd into your gem directory
rake install
Chances are, that your downloaded gem will know rake install
, too.

- 12,444
- 5
- 57
- 74
-
3this seems like the best modern answer. accepted answer is from 8 years ago – sixty4bit Jun 03 '16 at 20:33
-
this is useful for those who create gems but not so much for those who simply want to install a prebuilt one – Igor Skochinsky Oct 20 '20 at 13:23
If you want to work on a locally modified fork of a gem, the best way to do so is
gem 'pry', path: './pry'
in a Gemfile.
... where ./pry
would be the clone of your repository. Simply run bundle install
once, and any changes in the gem sources you make are immediately reflected. With gem install pry/pry.gem
, the sources are still moved into GEM_PATH
and you'll always have to run both bundle gem pry
and gem update
to test.

- 15,870
- 7
- 64
- 76
if you download the project file from github or other scm host site, use gem build to build the project first, so you can get a whatever.gem file in current directory. Then gem install it!

- 324
- 3
- 14
Go to the path in where the gem is and call gem install -l gemname.gem

- 1,648
- 12
- 20
Well, it's this my DRY installation:
- Look into a computer with already installed gems needed in the cache directory (by default:
[Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache
) - Copy all "
*.gems
files" to a computer without gems in own gem cache place (by default the same patron path of first step:[Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache
) - In the console be located in the gems cache (cd
[Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache
) and fire thegem install anygemwithdependencieshere
(by examplecucumber-2.99.0
)
It's DRY because after install any gem, by default rubygems put the gem file in the cache gem directory and not make sense duplicate thats files, it's more easy if you want both computer has the same versions (or bloqued by paranoic security rules :v)
Edit: In some versions of ruby or rubygems, it don't work and fire alerts or error, you can put gems in other place but not get DRY, other alternative is using launch integrated command
gem server
and add the localhost url in gem sources, more information in: https://guides.rubygems.org/run-your-own-gem-server/

- 1,843
- 2
- 21
- 21
You can download gems from https://rubygems.org/gems/ or build you local gem via bundle and rack.
eg:
- bundle gem yourGemName
- rake install
Take care of installing dependencies before installing actual gems.
- gem install --local /pathToFolder/xxx-2.6.1.gem
Note: If using fluentd td-agent and ruby on same machine. Please make sure to use td-agent's td-agent-gem command. td-agent has own Ruby.

- 341
- 4
- 11