O'Reilly logo

Ruby Cookbook by Leonard Richardson, Lucas Carlson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.7. Distributing Your Gems

Problem

You've packaged your software as a Ruby gem, but nobody knows about it. You want to make your gem easy to find and install, so that your genius does not go unrecognized.

Solution

The simplest solution (for you, at least) is to upload your .gem file to a web site or FTP site. Your users can download the .gem file, then install it by passing the filename into the gem install command:

	$ wget http://www.example.com/gems/my_gem-1.0.4.gem
	--10:40:10-- http://www.example.com/gems/my_gem-1.0.4.gem
	           => `my_gem-1.0.4.gem'
	Resolving gems.example.com… 204.127.202.4
	Connecting to gems.example.com|204.127.202.4|:80… connected.
	HTTP request sent, awaiting response… 200 OK
	Length: 40,823 (40K) [text/plain]

	100%[====================================>] 40,823        46.96K/s

	10:40:11 (46.85 KB/s) - `my_gem-1.0.4.gem' saved [40823/40823]

	$ gem install ./my_gem-1.0.4.gem
	Attempting local installation of './my_gem-1.0.4.gem'
	Successfully installed my_gem, version 1.0.4
	Installing RDoc documentation for my_gem-1.0.4…

If your gem has dependencies, the end user must separately install the dependencies before installing a downloaded gem, or the gem command will become confused and die. This will happen even if the user specifies the --include-dependencies flag:

 $ gem install --include-dependencies ./my_gem_with_dependency-1.0.0.gem Attempting local installation of './my_gem_with_dependency.1.0.0.gem' ERROR: Error installing gem ./my_gem_with_dependency-1.0.0.gem[.gem]: my_gem_with_dependency ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required