“未找到文件:lib"使用 RVM 切换到旧 Rails 版本时 [英] "File not found: lib" when switching to older rails version using RVM

查看:29
本文介绍了“未找到文件:lib"使用 RVM 切换到旧 Rails 版本时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有 rails 3.0.3,我正在尝试下载和使用 3.0.1 版.我已经下载并安装了 RVM 并在终端中输入了以下代码(我有一个 Mac OS X 10.6.5):

I currently have rails 3.0.3 and am trying to download and use version 3.0.1. I've downloaded and installed RVM and inputted the following code in Terminal (I have a Mac OS X 10.6.5):

rvm use 1.8.7
rvm gemset create rails3.0.1
rvm 1.8.7@rails3.0.1
sudo gem install rails --version=3.0.1

由于用户权限或我缺乏权限,我使用 sudo gems.无论如何,在我输入最后一行代码后:"sudo gem install rails --version=3.0.1" 我收到以下错误:

I use sudo gems because of the user permissions, or my lack there of. Anyway, after I enter the last line of code: "sudo gem install rails --version=3.0.1" I get the following error:

Successfully installed rails-3.0.1
1 gem installed
Installing ri documentation for rails-3.0.1...
File not found: lib

我不仅显然无法切换 rails 的版本,即使看起来好像我安装了多个版本,但每次我尝试查看我当前拥有的 rails 版本时,我都会得到以下结果:

Not only can I apparently not able to switch versions of rails, even though it appears as though I have multiple versions installed, every time I try to check to see what version of rails I currently have I get the following result:

rails -v
/Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find  RubyGem rails (>= 0) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate'
from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18

另外,我已经安装了 Rdoc 和 Xcode(我已经做了研究,其他建议都指向安装).我是一个 RoR 新手,尤其是 RVM 新手,所以我很想对这种疯狂进行解释和解决方案.

Also, I've already installed Rdoc and Xcode (I've done research and other suggestions pointed to installing both). I'm a RoR newbie, and especially an RVM newbie, so I would love an explanation and a solution to this madness.

感谢阅读!

推荐答案

我觉得你在这里出轨了(哈哈):

I think you went off the rails (ha-ha) right here:

sudo gem install rails --version=3.0.1

RVM 文档对此有以下说明:

不要使用 sudo...

DO NOT use sudo...

使用 RVM gems.当你做sudo 您正在以 root 身份运行命令,另一个 shell 中的另一个用户和因此,RVM 的所有设置done 被忽略,而命令在 sudo 下运行(这样的事情如 GEM_HOME 等...).所以重申一下,只要你'sudo'你就在运行作为 root 系统用户,它将清理你的环境以及它创建的任何文件都无法由您的用户修改,并将导致奇怪的事情发生.(你会开始认为有人有一个你的巫毒娃娃应用...)

to work with RVM gems. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening. (You will start to think that someone has a voodoo doll of your application...)

这篇关于“未找到文件:lib"使用 RVM 切换到旧 Rails 版本时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆