Can “gem install” be configured to install executables outside /usr/bin/ by default?

By default, when you sudo gem install thegemname it will install executables into /usr/bin/

Is there a way to change this? For example, to install them into /usr/local/rubygems/bin (or any other path)?

The path doesn't seem to be hard-coded into the gemspec file, so I don't see why this shouldn't be possible (although I have very little experience with Ruby/Gems)


See and specify a ~/.gemrc which defines a gemhome variable.

For example:

gemhome: /usr/local/rubygems

You can also place this file in /etc/gemrc

Alternatively you can set the GEM_HOME env-variable:

$ export GEM_HOME=/tmp/gemtest
$ gem install bundler
$ ls /tmp/gemtest/bin/

I'm adding this as an answer so that it is obvious when I run into this problem again :)

First, move all the bins in /var/lib/gems/1.8/bin/ to /usr/bin/. If you don't do this, then uninstalling or updating a gem will not remove the binary from the original bin directory.

You may also wish to remove the old path from $PATH

Next, edit ~/.gemrc and add (or update) the following line:

gem: --bindir /usr/bin

This overrides gem so that it always uses /usr/bin/ as the bin dir.

No need to update the path (especially messy for multiple-user machines).

Need Your Help

How to access a private Map in JUnit using reflections?

java testing reflection junit

I have a connector class (SVNConnector) which should be junit tested. There is a private map called private Map<String, SVNRepository> connectionMap which should be accessed in JUnit, but thi...

xcode Picker loading subsequent components after selection

xcode components picker

Here's what I would like to do. If someone knows if this is possible, and how, that would be great. I have a picker with three components. The second two components can change value based on which