ruby on rails -v给出错误

时间:2013-06-07 21:46:18

标签: ruby-on-rails ruby

我收到此错误

/usr/lib64/ruby/site_ruby/1.8/rubygems.rb:926:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:244:in `activate_dep'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:236:in `activate'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:1307:in `gem'
from /usr/bin/rails:18

我开始使用红宝石1.8.7& rails 2.3.11 然后我安装了rvm 然后安装ruby 2.0.0& gem install rails 3.2.13 然后开始出现上述错误。 任何帮助将不胜感激,谢谢。 我认为这是某种路径问题,但无法弄清楚,对unix的东西不太了解。顺便说一下,我没有root权限。

这是我的.bashrc if help

 # .bashrc

   # User specific aliases and functions
   alias mv='mv -i'  
   alias rm='rm -i'
        alias cp='cp -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export HPATH=$HOME
export GEM_HOME=$HPATH/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HPATH/ruby/gems/bin
export PATH=$PATH:$HPATH/ruby/gems

这是.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$

1 个答案:

答案 0 :(得分:0)

rvm use 2.0.0

将切换到ruby 2.0.0

然后,您可以安装rails并创建名为rails-3.2.13

的gemset
rvm use 2.0.0@rails-3.2.13 --create

然后

gem install rails -v 3.2.13

您也可以通过--default开关将2.0.0设为默认红宝石

如果所有已安装的ruby版本以及使用

的当前和/或默认版本,您都可以看到列表
rvm list

这会产生这样的输出

 rvm rubies

   ruby-1.9.3-p385 [ x86_64 ]
=* ruby-1.9.3-p392 [ x86_64 ]
   ruby-2.0.0-p0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

更新

此外,自您上次发表评论以来,这似乎是一个PATH问题。我不确定你的bash_profile但是PATH对于rvm可能有误。只需使用

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

bash_profile

并在你的`.bashrc'试试这个

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting