Error sudo: gem: command not found

linux, ruby, rubygems, sudo

Solution

Try without `sudo`. You should only use `sudo` if you did a root installation of ruby, which is not recommended.

Problem

I'm trying to install rubyrep on CentOS, and when executing `sudo gem install rubyrep` I get the error `sudo: gem: command not found`. Sudo and gem are both installed and working, just not when combined. My setting: ``` [rubyrep]# which sudo /usr/bin/sudo [rubyrep]# which gem /usr/local/rvm/rubies/ruby-2.1.2/bin/gem [rubyrep]# which ruby /usr/local/rvm/rubies/ruby-2.1.2/bin/ruby [rubyrep]# $PATH -bash: /usr/local/rvm/gems/ruby-2.1.2/bin:/usr/local/rvm/gems/ruby-2.1.2@global/bin:/usr/local/rvm/rubies/ruby-2.1.2/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory ```

Original source

Related problems