macos 运行 brew 会产生警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4574927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:31:12  来源:igfitidea点击:

Running brew generates warnings

macososx-snow-leopardhomebrew

提问by Chiron

I installed the latest Homebrew on OS X 10.6.5
Running any command generates this warning:

我在 OS X 10.6.5 上安装了最新的 Homebrew
运行任何命令都会生成此警告:

/usr/local/Library/Homebrew/global.rb:34: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

/usr/local/Library/Homebrew/global.rb:34: 警告:不安全的世界可写目录 /usr/local/bin 在 PATH,模式 040777

Why I'm getting this warning? and how to remedy?

为什么我会收到此警告?以及如何补救?

回答by Andrey Tarantsov

I had the same problem and just fixed it with these 3 commands, roughly taken from Homebrew installation script:

我遇到了同样的问题,只是用这 3 个命令修复了它,大致取自 Homebrew 安装脚本:

sudo chgrp -R admin /usr/local
sudo chmod -R g+rwx /usr/local
sudo chmod -R o-w /usr/local

回答by Ryan McGeary

First, there are two brew commands that are helpful when debugging problems. They are:

首先,有两个 brew 命令在调试问题时很有帮助。他们是:

$ brew doctor
$ brew missing

Second, Homebrew is telling you that /usr/local/binis set to be too permissive in who can write to that directory -- a potential security problem. To remedy this, you can reset your permissions back to what Homebrew intended.

其次,Homebrew 告诉您,/usr/local/bin谁可以写入该目录的设置过于宽松——这是一个潜在的安全问题。为了解决这个问题,您可以将您的权限重置回 Homebrew 的意图。

$ chmod 755 /usr/local/bin

If you get an error while trying to do this, it may mean that your /usr/local directory (and subdirectories) are owned by the wrong user. If that's the case, I would consider deleting your /usr/local directory and reinstalling Homebrew correctly. Alternatively, you can override the error by prefixing the last command with sudo and entering your admin password:

如果您在尝试执行此操作时遇到错误,则可能意味着您的 /usr/local 目录(和子目录)归错误的用户所有。如果是这种情况,我会考虑删除您的 /usr/local 目录并正确重新安装 Homebrew。或者,您可以通过在最后一个命令前面加上 sudo 并输入您的管理员密码来覆盖错误:

$ sudo chmod 755 /usr/local/bin

回答by Asmus

This is a security feature of ruby, you can change permissions on the directory /usr/local/bin to get rid of this by running:

这是 ruby​​ 的一个安全特性,您可以通过运行更改目录 /usr/local/bin 的权限来摆脱它:

sudo chmod go-w /usr/local/bin

and entering your password on the prompt.

并在提示中输入您的密码。

You do notneed to change ownership and neithershould delete /usr/local as Ryan suggested (that would require you to rebuild everything you′ve accomplished so far), the directory is owned by root and this is the usual way.

没有必要改变所有权,也不应删除的/ usr / local作为瑞安建议(这将需要您重建一切你所取得的成就),该目录由root拥有,这是通常的方式。