4

I don't have a desire at the moment to learn Ruby, but I just want to know what the difference is between gem install --bindir ~/path/ and gem install --user-install as long as each of the paths are in my $PATH.

1 Answer 1

6

Look at the Ruby GEM command reference here:

-n, -​-bindir DIR - Directory where binary files are located -​-[no-]user-install - Install in user’s home directory instead of GEM_HOME. 

Effectively, and operationally you—as an end user using Ruby—would not really notice a difference if the file paths are in your $PATH. But each command clearly deals with a different filesystem aspect of a Ruby GEM install.

-​-bindir

-​-bindir refers to the binary directory. Many Ruby GEMS install Ruby script files as part of their core library function but also install a “binary” as part of their install process. Meaning, if you are a Ruby programmer you might want to install a Ruby GEM so you can have a usable reference to it’s core code within your own custom code. But a binary file that performs an equivalent or “helper” task is installed along side those Ruby GEM library files. From a filesystem management point of view, some users might want to install those binary files in a separate directory instead of the default Ruby GEMs directory.

-​-user-install

So while -​-bindir is an option to control where binary files associated with Ruby GEMs get installed, -​-user-install is a manual override for where all Ruby GEM files get installed; binaries, libraries and other stuff like that. By using -​-user-install you are instructing Ruby GEM to install GEMs in the ~/.gem directory which is—of course—in your user’s home directory. Without the -​-user-install option, the Ruby GEM files would be installed to wherever the default GEM_HOME path is.

Changing the default file path with --user-install will not negatively affect anything about operation. The Ruby GEMs would just be installed in a ~/.gem directory—which is in your home directory—and Ruby will know to check there as well as it’s own default path for updates.

2
  • Thanks for taking the time to clarify that for me. Will using --user-install for a gem (like Jekyll for instance) affect anything about operation, future updates, etc.? Or was Ruby written to operate the same way whether gems are in GEM_HOME or elsewhere? Commented Jul 21, 2016 at 16:09
  • I don't have a ~/.gemrc file, even after installation. Were you implying that the installation would create it or is that another step I need to take manually? Commented Jul 21, 2016 at 16:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.