rubygems – 您没有/var/lib/gems/2.3.0目录的写入权限 - 代码日志

rubygems – 您没有/var/lib/gems/2.3.0目录的写入权限

我在Ubuntu 16.04上安装了ruby。

$which ruby  

/usr/bin/ruby

$ruby -v 

ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu]

$gem install bundler 

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.

任何帮助将不胜感激!

您首先需要卸载Ubuntu安装的ruby,像sudo apt-get remove ruby​​。

然后根据他们的文档使用rbenvruby-build重新安装ruby:

cd $HOME
sudo apt-get update 
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.3.1
rbenv global 2.3.1
ruby -v

最后一步是安装Bundler:

gem install bundler
rbenv rehash

然后享受!

德里克

http://stackoverflow.com/questions/37720892/you-dont-have-write-permissions-for-the-var-lib-gems-2-3-0-directory

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:rubygems – 您没有/var/lib/gems/2.3.0目录的写入权限