The error message here shows that while your PATH is set to use RVM's Ruby, the GEM_HOME and/or GEM_PATH environment variables are not set.
These variables are important because they tell Ruby where to install and look for gems.
To fix this, you need to set the GEM_HOME and GEM_PATH environment variables. You can do this by adding the following lines to your shell profile file (like .bashrc
, .bash_profile
, or .zshrc
):
export GEM_HOME="$HOME/.gem"
export GEM_PATH="$HOME/.gem"
After adding these lines, you need to source your shell profile file to apply the changes:
source ~/.bashrc # or
source ~/.bash_profile # or
source ~/.zshrc
Then, you can check if the environment variables are set correctly by running:
echo $GEM_HOME
echo $GEM_PATH
If everything is set up correctly, both commands should output the path to your .gem directory.