简体   繁体   English

为什么安装Rails会出现“写权限”错误?

[英]Why do I get “write permission” errors installing Rails?

When I use rvm use 1.9.2 , I get Rails v3.0.0: 当我使用rvm use 1.9.2 ,我得到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

When I use rvm use 2.0.0 , I get Rails v3.2.13: 当我使用rvm use 2.0.0 ,我得到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

I need Rails v3.2.13 with Ruby 1.9.2. 我需要Rails v3.2.13和Ruby 1.9.2。

When I used rvm use 1.9.2 --default and gem install rails -v 3.2.13 , I got the following error: 当我使用rvm use 1.9.2 --defaultgem install rails -v 3.2.13 ,我收到以下错误:

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. 

Is because, at some point, you used sudo or were running as root when you use RVM to install a gem. 是因为,在某些时候,当您使用RVM安装gem时,您使用了sudo或以root身份运行。 When that happened, the ownership of files and/or folders changed to root's permissions, which you can't override running as you. 发生这种情况时,文件和/或文件夹的所有权已更改为root权限,您无法覆盖正在运行的权限。

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. 您不希望以root身份运行,或者在运行rvmgem命令时使用sudo EVER ,如果您安装了RVM以在主目录中的沙箱中提供Ruby。

To fix this, try this command: 要解决此问题,请尝试以下命令:

sudo chown -R vikas ~/.rvm

That will use sudo to change ownership of all files in the ~/.rvm directory to your own account, from the "root" user. 这将使用sudo从〜“root”用户将〜/ .rvm目录中所有文件的所有权更改为您自己的帐户。 This will take at least a few seconds so let it run. 这将需要至少几秒钟,所以让它运行。

Once that has run, you should be able to switch to each of your Rubies and delete the installed Rails: 一旦运行,您应该能够切换到每个Rubies并删除已安装的Rails:

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

Then: 然后:

rvm use 2.0.0
gem uninstall rails
gem install rails -v [whatever version you want]
gem install rails -v 
rvm use 1.9.2 --default Using /home/vikas/.rvm/gems/ruby-1.9.2-p320 
gem install rails -v 3.2.13

rvm is software tool by which you can manage multiple version of rubies on your system. rvm是一种软件工具,您可以通过它来管理系统上的多个版本的红宝石。

for each ruby version you can create a gemset which is just a group of gems. 对于每个ruby版本,您可以创建一个gemset,它只是一组宝石。

each ruby version you install has a 'default' gemset. 您安装的每个ruby版本都有一个'默认'gemset。

and it seems that you have installed rails 3.0 for ruby 1.9.2 and rails 3.2.13 for ruby 2.0 似乎你已经为ruby 1.9.2安装了rails 3.0,为ruby 2.0安装了rails 3.2.13

you can create your own gemset by command 你可以通过命令创建自己的gemset

rvm gemset create rails3

this will create a gemset named 'rails3' and to use it you have to do 这将创建一个名为'rails3'的宝石集并使用它你必须这样做

rvm gemset use rails3

and in this gemset you can install any version of rails you want. 在这个gemset中,您可以安装所需的任何版本的rails。

with command 用命令

gem install rails -v='3.2.13'

for more info see rvm doc. 有关更多信息,请参阅rvm doc。

https://rvm.io/ https://rvm.io/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM