Ruby Language Installation Linux - troubleshooting gem install

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

First UC in the example Gems $> gem install nokogiri can have a problem installing gems because we don't have the permissions for it. This can be sorted out in more then just one way.

First UC solution a:

U can use sudo. This will install the gem for all the users. This method should be frowned upon. This should be used only with the gem you know will be usable by all the users. Usualy in real life you don't want some user having access to sudo.

$> sudo gem install nokogiri

First UC solution b

U can use the option --user-install which installs the gems into your users gem folder (usualy at ~/.gem)

&> gem install nokogiri --user-install

First UC solution c

U can set GEM_HOME and GEM_PATH wich then will make command gem install install all the gems to a folder which you specify. I can give you an example of that (the usual way)

  • First of all you need to open .bashrc. Use nano or your favorite text editor.
$> nano ~/.bashrc
  • Then at the end of this file write
export GEM_HOME=$HOME/.gem
export GEM_PATH=$HOME/.gem
  • Now you will need to restart terminal or write . ~/.bashrc to re-load the configuration. This will enable you to use gem isntall nokogiri and it will install those gems in the folder you specified.


Got any Ruby Language Question?