简体   繁体   English

在 Homebrew 中安装错误

[英]Installing in Homebrew errors

Attempting to install rvm and ruby 1.9.2尝试安装 rvm 和 ruby​​ 1.9.2

I already installed homebrew and git, but couldn't get complete updates because I kept getting permission errors.我已经安装了 homebrew 和 git,但无法获得完整的更新,因为我不断收到权限错误。 Re-installed Snow Leopard and repaired permissions.重新安装雪豹并修复权限。

Now this happens...现在出现这种情况...

$ brew install wget $ brew 安装 wget

Error: Cannot write to /usr/local/Cellar错误:无法写入 /usr/local/Cellar

sudo chown -R $USER /usr/local

You'll have to give yourself ownership of /usr/local/ using that line right there.您必须使用该行赋予自己/usr/local/所有权。 I had to do this myself after using the ruby one-liner at the top of the official docs to install Homebrew.在使用官方文档顶部的 ruby​​ one-liner 安装 Homebrew 后,我不得不自己这样做。 Worked like a charm for me.对我来说就像一种魅力。 It ought to be the only time you'll ever need to sudo with Homebrew.这应该是您唯一需要使用 Homebrew sudo时间。

I'm not sure if the ruby one-liner does this.我不确定 ruby​​ one-liner 是否能做到这一点。 If it did, then something else on my system took control of /usr/local since.如果是这样,那么我系统上的其他东西就控制了/usr/local

Edit : I completely missed this, but @samvermette didn't (see replies to my answer): if you run this command above and have something installed via homebrew that requires special user permissions, like mysql , make sure to give those permissions back (as the above command gives recursive ownership to everything inside /usr/local to you ( $USER ). In the case of mysql, it's…编辑:我完全错过了这一点,但@samvermette没有(请参阅对我的回答的回复):如果您在上面运行此命令并通过自制软件安装了需要特殊用户权限的内容,例如mysql ,请确保将这些权限还给(因为上面的命令将/usr/local所有内容的递归所有权授予您( $USER )。在 mysql 的情况下,它是......

sudo chown -RL mysql:mysql /usr/local/mysql/data

I had this issue after upgrading to Mavericks, and this page was the top search result when googling the error message.升级到 Mavericks 后我遇到了这个问题,这个页面是谷歌搜索错误消息时的顶级搜索结果。 I continued searching and found this answer on stack overflow.com .我继续搜索并在 stack overflow.com 上找到了这个答案 Put concisely, it is:简而言之,就是:

sudo chmod a+w /usr/local/Cellar

This fixed the issue for me, and as it only changes permissions for the specific path referenced in the error message, seemed unlikely to have negative side effects with other installations.这为我解决了这个问题,因为它只更改错误消息中引用的特定路径的权限,似乎不太可能对其他安装产生负面影响。

I'm putting this answer here for anyone else who may find this page first like I did.我将这个答案放在这里,供其他可能像我一样首先找到此页面的人使用。 However, credit should go to jdi .但是,应该归功于 jdi

You can allow only Admin users writing into /usr/local/ ?您只能允许管理员用户写入/usr/local/吗?

chgrp -R admin /usr/local
chmod -R g+w /usr/local
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew

Since that each user who belongs to Admin group, will be able to install new dependencies.因为属于 Admin 组的每个用户都可以安装新的依赖项。

On High Sierra you need the following command cause chown will not work:在 High Sierra 上,您需要以下命令,因为 chown 不起作用:

sudo chown -R $(whoami) $(brew --prefix)/*须藤 chown -R $(whoami) $(brew --prefix)/*

Link:链接:

https://github.com/Homebrew/brew/issues/3228 https://github.com/Homebrew/brew/issues/3228

卸载并重新安装 HomeBrew 即可解决问题

I suggest ensuring that the current user is a member of the group that owns /usr/local.我建议确保当前用户是拥有 /usr/local 的组的成员。 I believe by default, that group is wheel .我相信默认情况下,该组是wheel To make yourself a member of that group:要使自己成为该组的成员:

$ sudo dscl . append /Groups/wheel GroupMembership $USER

Although something of an inelegant hammer, it has the intended effect - enabling access to items in /usr/local that are intended only for use (read/write) by elevated members.虽然有点不雅的锤子,但它具有预期的效果 - 允许访问/usr/local中仅供提升成员使用(读/写)的项目。 This approach has benefits of the other above because it takes advantage of the group memberships, enabling multiple (authorized) users on the system to use homebrew.这种方法具有上述其他方法的优点,因为它利用了组成员资格,使系统上的多个(授权)用户能够使用自制软件。

How did you install Homebrew?你是如何安装 Homebrew 的? Their official installation instructions include running a ruby script.他们的官方安装说明包括运行 ruby​​ 脚本。 That should take care of the permission issues for you.这应该为您解决许可问题。

If you don't want to run a script, there is a section of that page called "Installing to /usr/local for Developers" that explains the change in permissions needed for the /usr/local directory.如果您不想运行脚本,该页面中有一个名为“为开发人员安装到 /usr/local”的部分,解释了 /usr/local 目录所需的权限更改。

EDIT : As mentioned in the comments it's a bad idea to use sudo with homebrew, so don't use the following answer!编辑:如评论中所述,将 sudo 与自制软件一起使用是个坏主意,所以不要使用以下答案!


You can also prevent this error if you execute the command with sudo:如果使用 sudo 执行命令,也可以防止此错误:

$ sudo brew install wget

But take care of using sudo because you can make a lot of mistakes.但是要小心使用sudo因为你可能会犯很多错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM