为什么我会获得“写入权限"?安装 Rails 时出错? [英] Why do I get "write permission" errors installing Rails?

查看:46
本文介绍了为什么我会获得“写入权限"?安装 Rails 时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 rvm use 1.9.2 时,我得到 Rails v3.0.0:

When I use rvm use 1.9.2, I get Rails v3.0.0:

vikas@admin1-DL-H61MXEL:~$ rvm use 1.9.2 --default
Using /home/vikas/.rvm/gems/ruby-1.9.2-p320
vikas@admin1-DL-H61MXEL:~$ rails -v
Rails 3.0.0

当我使用 rvm use 2.0.0 时,我得到 Rails v3.2.13:

When I use rvm use 2.0.0, I get Rails v3.2.13:

vikas@admin1-DL-H61MXEL:~$ rvm use 2.0.0
Using /home/vikas/.rvm/gems/ruby-2.0.0-p195
vikas@admin1-DL-H61MXEL:~$ rails -v
Rails 3.2.13

我需要 Rails v3.2.13 和 Ruby 1.9.2.

I need Rails v3.2.13 with Ruby 1.9.2.

当我使用 rvm use 1.9.2 --defaultgem install rails -v 3.2.13 时,出现以下错误:

When I used rvm use 1.9.2 --default and gem install rails -v 3.2.13, I got the following error:

While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory. 

This is the error I'm facing now.

推荐答案

出现错误的最可能原因:

The most likely reason you're getting the error:

(Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory. 

是因为,在某些时候,您使用了 sudo 或在使用 RVM 安装 gem 时以 root 身份运行.发生这种情况时,文件和/或文件夹的所有权更改为 root 的权限,您无法以自己的身份运行.

Is because, at some point, you used sudo or were running as root when you use RVM to install a gem. When that happened, the ownership of files and/or folders changed to root's permissions, which you can't override running as you.

您不想以 root 身份运行,或者在运行 rvmgem 时使用 sudo EVER如果您安装了 RVM,则可以在主目录的沙箱中提供 Ruby 命令.

You don't want to run as root, or use sudo EVER when running rvm or gem commands if you have a RVM installation to provide Ruby in a sandbox in your home directory.

要解决此问题,请尝试以下命令:

To fix this, try this command:

sudo chown -R vikas ~/.rvm

这将使用 sudo 将 ~/.rvm 目录中所有文件的所有权从root"用户更改为您自己的帐户.这至少需要几秒钟,所以让它运行.

That will use sudo to change ownership of all files in the ~/.rvm directory to your own account, from the "root" user. This will take at least a few seconds so let it run.

运行后,您应该能够切换到每个 Ruby 并删除已安装的 Rails:

Once that has run, you should be able to switch to each of your Rubies and delete the installed Rails:

rvm use 1.9.2
gem uninstall rails
gem install rails -v 3.2.13

那么:

rvm use 2.0.0
gem uninstall rails
gem install rails -v [whatever version you want]
gem install rails -v 

这篇关于为什么我会获得“写入权限"?安装 Rails 时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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