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.
- 53,069
- 19
- 162
- 212
- 3,923
- 3
- 27
- 34
1 Answers
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.
- 53,069
- 19
- 162
- 212
-
Thanks for taking the time to clarify that for me. Will using `--user-install` for a gem (like [Jekyll](https://jekyllrb.com/) 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? – jsejcksn Jul 21 '16 at 16:09
-
@jsejcksn Changing the default file path with `--user-install` will not negatively affect anything about operation. Whatever that new path is would be just added to your `~/.gemrc` file so your local Ruby install would be able to keep track of it like anything else and do whatever it has to do to keep things running. – Giacomo1968 Jul 21 '16 at 16:12
-
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? – jsejcksn Jul 21 '16 at 16:48
-
@jsejcksn My bad on the `~/.gemrc`; I mixed up concepts and now realize that the locally installed Ruby GEMs will be installed in the `~/.gem` path which is—of course—in your user’s home directory. Updated my answer to clear this up. – Giacomo1968 Jul 21 '16 at 23:50