1. 程式人生 > >Rvm 進行gem安裝時必須輸入密碼Your user account isn't allowed to install to the system RubyGems 解決方案

Rvm 進行gem安裝時必須輸入密碼Your user account isn't allowed to install to the system RubyGems 解決方案

class nbsp mina required it is code script *** mas

今天開發過程中,從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 解決方案