您没有/var/lib/gems/2.3.0 目录的写入权限 [英] You don't have write permissions for the /var/lib/gems/2.3.0 directory

查看:16
本文介绍了您没有/var/lib/gems/2.3.0 目录的写入权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 ubuntu 16.04 上安装了 ruby​​.

I have ruby installed on my ubuntu 16.04.

$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​​.

You first need to uninstall the ruby installed by Ubuntu with something like sudo apt-get remove ruby.

然后使用 rbenvruby-build 根据他们的文档:

Then reinstall ruby using rbenv and ruby-build according to their docs:

cd $HOME
sudo apt-get update
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn

现在我们将安装 rbenv(推荐,请参阅 docs)

Now we will install rbenv (recommended, see docs)

cd
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 3.0.1
rbenv global 3.0.1
ruby -v

最后一步是安装Bundler:

The last step is to install Bundler:

gem install bundler
rbenv rehash

那就尽情享受吧!

德里克

更新:此答案已在 Ubuntu 20.04 上更新并测试成功.

Update: This answer has been updated and tested successfully on Ubuntu 20.04.

这篇关于您没有/var/lib/gems/2.3.0 目录的写入权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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