Firstly, I am new to Linux so excuse me if any terminology is wrong; I'll try to phrase the problem as competently as possible.

I have installed Ruby (2.4.0) via Linuxbrew. The ruby command works fine; it installed correctly. However, when I try to use the gem command (which Ruby should have installed) I receive this error: bash: /usr/bin/gem: No such file or directory

Now, because I installed this with Linuxbrew I know that this directory isn't correct. For example:

result of which gem : /home/me/.linuxbrew/bin/gem

result of which ruby : /home/me/.linuxbrew/bin/ruby

Therefore, it seems gem is installed but the gem command isn't linked to the correct path. I assume I need to direct the gem command to the path of which gem as opposed to /usr/bin/gem that bash is saying doesn't exist. How would I go about changing this? I tried in vain to change the bash_profile but I'm not sure what to do.

Again, excuse me if ruby and gem are not referred to as commands and if the problem isn't the "default directory" as stated in the title. I wasn't sure how to label it.

I'm sure it's an easy thing to fix, I just have no idea how to search for it!

Basically, how can I make gem execute this: /home/me/.linuxbrew/bin/gem instead of looking for the program in /usr/bin/gem?


My bash_profile contains "export PATH="$HOME/.linuxbrew/bin:$PATH" and .profile: PATH="/home/me/.linuxbrew/sbin:$PATH". echo $PATH also contains "/home/me/.linuxbrew/bin". I'm not sure why "gem" doesn't find the binary; it exists as I can run "/home/steve/.linuxbrew/bin/gem" without issues. All other packages in this folder work without prefixing the full directory; only "gem" and "rails" aren't found.