Rvm 进行gem安装时必须输入密码Your user account isn't allowed to install to the system RubyGems 解决方案

Posted lwh-note

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rvm 进行gem安装时必须输入密码Your user account isn't allowed to install to the system RubyGems 解决方案相关的知识,希望对你有一定的参考价值。

今天开发过程中,从master拉下代码后重启项目,想用控制台时,却发现需要密码??并且三次密码确认后还是疯狂报错。

当时第一想到是rvm版本不一致,随即则检查了版本跟gem生成,当确认rvm版本无误时,且强制使用sudo安装却需要一条条执行gem install ***安装gem包时,就令我抓狂了。

 

警告提示如下:

Your user account isn‘t allowed to install to the system RubyGems.
You can cancel this installation and run:

bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.

或者如下:

RVM is not a function, selecting rubies with ‘rvm use ...‘ will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

 

猜测原因:

     rbenv 要往你系统的自带Ruby里面安装gem,但是你的用户帐户不允许系统安装RubyGems,所以要你输入密码赋予权限

 

解决方案(控制台依次输入):

1 echo [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" >>~/.bashrc
2 
3 source ~/.bashrc
4 
5 ruby -v

然后就解决了,可以继续嗨皮开发了!!

以上是关于Rvm 进行gem安装时必须输入密码Your user account isn't allowed to install to the system RubyGems 解决方案的主要内容,如果未能解决你的问题,请参考以下文章

pg gem 安装错误 - lion osx、bundler 和 rvm

即使安装了 gem,RVM Bundle Install Missing Gem 错误

[fastlane] [gem] [rvm] [ruby]

无法加载带有本机扩展的 gem:fresh 10.8、xcode 4.5、rvm

rvm pod gem 等常用命令

在 OSX 中卸载所有已安装的 gem?