找不到Rubygems命令

时间:2017-04-21 20:26:45

标签: ruby rubygems

Centos 7

我已经安装了ruby 2.1.2和rubygems,但是当我运行rubygems --version时,我收到错误rubygems:command not found。

我的$ PATH是/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/lib/ruby/gems/2.1.0:/root/.gem/ruby/2.1.0

gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.11
  - RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.1.0
  - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.1.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.1.0
     - /root/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /sbin
     - /bin
     - /usr/sbin
     - /usr/bin
     - /root/bin
     - /root/ruby-2.1.2
     - /usr/bin/gem

安装的yum list显示了rubygems.noarch

我需要做些什么来让rubygems工作?

1 个答案:

答案 0 :(得分:1)

要在centOS上安装rubyrubygems,请在终端上运行

sudo yum install ruby
sudo yum install rubygems

要检查ruby和rubygems的版本,请运行

ruby -v
gem -v

注意: gem --versiongem -v

相同

使用以下方式更新宝石列表:

sudo gem update
sudo gem update --system

现在,您可以使用命令

安装任何gem
gem install <gem_name>

例如,要在centOS上安装rails,请运行

sudo gem install rails