gem: command not found
gem: command not found means the RubyGems package manager isn’t on your PATH — Ruby isn’t installed, or the gem binary directory isn’t in your shell environment.
What It Means
RubyGems (gem) is the standard package manager bundled with Ruby. When you type gem install and see “command not found”, it means your operating system can’t locate the gem executable. This usually indicates Ruby itself is missing, or the directory containing the gem binary isn’t in your PATH environment variable.
Why It Happens
- Ruby is not installed on your system at all.
- Ruby is installed but the
gembinary isn’t in your shell’sPATH. - You’re using a Ruby version manager (rbenv, RVM) that isn’t properly initialized.
- The Ruby installation is corrupted or incomplete.
- You installed Ruby via a package manager but the
rubygemspackage is separate.
How to Fix It
Step 1: Check if Ruby is installed
ruby --versionIf this also fails with “command not found”, Ruby isn’t installed. If it works but gem doesn’t, Ruby is installed but the gem binary path is missing from your PATH.
Step 2: Install Ruby via a version manager (recommended)
Using rbenv (simpler, preferred):
# Install rbenv and ruby-build
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# Install Ruby 3.3
rbenv install 3.3.0
rbenv global 3.3.0Using RVM (alternative):
# Install RVM
curl -sSL https://get.rvm.io | bash
source ~/.rvm/scripts/rvm
# Install Ruby
rvm install 3.3.0
rvm use 3.3.0 --defaultStep 3: Install Ruby via package manager
On Ubuntu/Debian:
sudo apt update
sudo apt install ruby-fullOn macOS:
brew install rubyOn Windows, download the RubyInstaller from rubyinstaller.org.
Step 4: Verify the gem command now works
gem --versionIf you still see “command not found”, check your PATH:
echo $PATH
# Ensure something like /home/user/.rbenv/shims or
# /usr/local/lib/ruby/gems is includedStep 5: Restart your shell
After installing Ruby or a version manager, restart your terminal or run:
exec $SHELL -lBuilt by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro