使用 rbenv 不适用于 sudo? [英] Using rbenv doesn't work with sudo?

查看:38
本文介绍了使用 rbenv 不适用于 sudo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何使用 sudo 的命令似乎都不适用于 RBenv.

Any commands that use sudo don't seem to work with RBenv.

我正在尝试安装 ActiveRecord 并且它说我没有写权限,所以当我尝试这个时:

I'm trying to install ActiveRecord and it says I don't have write permission, so when I try this:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1 directory.

它说:

sudo: gem: command not found

我该如何解决这个问题?

How can I get around this?

推荐答案

rbenv 和 RVM 等工具背后的想法是您不需要使用 sudo,因为您的整个 Ruby 环境作为沙箱存在于您自己的工作区中.

The idea behind tools like rbenv and RVM is that you don't need to use sudo, because your entire Ruby environment exists inside your own workspace as a sandbox.

RVM 允许多用户配置,尽管它最初是为单用户设计的.

RVM allows multi-user configurations though it was originally designed for single users.

据我所见或读过,rbenv 仅适用于单用户.在使用 rbenv 时,您决不需要使用 sudo 来操作或更改您的 Ruby 环境.如果你这样做了,那就有问题了.如果你尝试使用 sudo,你会把事情搞砸.您可能不会立即发现,但最终会弹出一些内容,您需要将文件的所有权更改回您.

As far as I've ever seen or read, rbenv is single-user only. At no time should you need to use sudo to manipulate or change your Ruby environment when using rbenv. If you do, something is wrong. If you try to use sudo, you'll screw things up. You might not find out immediately but eventually something will pop up and you'll need to change the ownership of the files back to you.

在 Linux 和 Mac OS 上,您可以很容易地使用:

On Linux and Mac OS you can do that pretty easily using:

sudo chown -R <your_user_name>:<your_group> ~/.rbenv

您必须以 sudo 的身份运行它,因为只有超级用户才能更改 root 拥有的文件的所有权.sudo 提升您的权限以允许您更改这些内容.

You have to run that as sudo because only the super-user can change ownership of files owned by root. sudo escalates your privileges to allow you to change those things.

这篇关于使用 rbenv 不适用于 sudo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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