Skip to content
gem: command not found

gem: command not found

DodaTech 3 min read

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 gem binary isn’t in your shell’s PATH.
  • 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 rubygems package is separate.

How to Fix It

Step 1: Check if Ruby is installed

ruby --version

If 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.0

Using 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 --default

Step 3: Install Ruby via package manager

On Ubuntu/Debian:

sudo apt update
sudo apt install ruby-full

On macOS:

brew install ruby

On Windows, download the RubyInstaller from rubyinstaller.org.

Step 4: Verify the gem command now works

gem --version

If 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 included

Step 5: Restart your shell

After installing Ruby or a version manager, restart your terminal or run:

exec $SHELL -l
Do I need to install RubyGems separately?
RubyGems is bundled with Ruby since version 1.9. Installing Ruby via any standard method (rbenv, RVM, package manager, RubyInstaller) automatically includes the gem command. No separate installation is needed.
Why does 'gem' work in one terminal but not another?
This usually means your shell configuration file (.bashrc, .zshrc) doesn’t load the Ruby version manager in all terminal sessions. Check that the rbenv or RVM initialization lines appear in the correct config file for the shell you’re using.
What is the difference between 'gem' and 'bundle'?
gem is RubyGems — the low-level package manager used to install, update, and manage Ruby libraries. bundle is Bundler — a higher-level tool that reads a Gemfile and resolves dependency versions before installing gems. Think of gem as npm and bundle as a lockfile resolver.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro