2013-07-12 40 views
0

我刚刚删除了ruby 1.9.1并安装了1.8.7,但当我寻找rails时,我的bash仍指向1.9.1。Ruby:`gem_original_require':没有这样的文件加载 - rails(LoadError)

[email protected]:~$ rails --version 
bash: /usr/local/bin/rails: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory 

[email protected]:~$ ruby --version 
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] 

任何人都可以帮忙吗?我如何让bash看看1.8.7?

+0

可能重复[如何告诉RubyGems的到别处?](http://stackoverflow.com/questions/17624139/how-to-tell -rubygems到看别处) –

回答

2

你的红宝石是非常古老的(截至本周,正式弃用)。你的宝石安装在/usr/local/bin也是很奇怪的。

你可能要考虑rbenv

这将很可能清理你的问题马上


在您rbenv设置,我编译我的红宝石这样

# start in your home directory 
cd $HOME  

# make a src folder for compiling ruby 
mkdir -p .src && cd .src  

# download ruby 
curl -O ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz  

# extract compressed file 
tar -xzf ruby-2.0.0-p247.tar.gz  

# cd to folder 
cd ruby-2.0.0-p247  

# configure 
./configure --prefix=$HOME/.rbenv/versions/2.0.0-p247 --with-opt-dir=/path/to/openssl --enable-shared  

# make and install 
make && make install  

# cleanup 
rm -rf ruby-2.0.0-p247 

现在让我们使用它!

# make rbenv aware of our new rubies 
rbenv rehash 

# set our new version as the default 
rbenv global 2.0.0-p247 

# let's check it out! 
ruby --version 
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0] 

现在让我们说rails去的

# install rails 
gem install rails 

# check the version 
rails --version 
Rails 4.0.0 
相关问题