如何解决 PATH 中不安全的世界可写目录 /usr,Ruby 上的模式 040777 警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26711249/
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-09-06 06:37:25  来源:igfitidea点击:

How to solve Insecure world writable dir /usr in PATH,mode 040777 warning on Ruby?

rubymacoscommand-line

提问by Jash Jacob

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb:213: warning: Insecure world writable dir /usr in PATH, mode 040777

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb:213: warning: Insecure world writable dir /usr in PATH, mode 040777

I've tried these two commands after searching for solutions on Stackexchange, but it didn't work for me. It still shows me the warning which I've pasted above.

在 Stackexchange 上搜索解决方案后,我尝试了这两个命令,但对我不起作用。它仍然向我显示我在上面粘贴的警告。

sudo chmod 775 /usr/local

sudo chmod go-w /usr/local/bin

How do I fix this warning message? I'm running OS X 10.9 Mavericks

如何修复此警告消息?我正在运行 OS X 10.9 Mavericks

回答by shellter

Learn to read the error messages closely.

学习仔细阅读错误消息。

Insecure world writable dir /usr in PATH

Note it's not saying /usr/local.

请注意,这不是说/usr/local.

To confirm this diagnosis, use

要确认此诊断,请使用

 ls -ld /usr
 drwxrwxrwx  14 ownerID  groupID     4096 Dec 10  2010 /usr
 #-------^-  is the world-writeable  part

As you know, you can fix it with

如你所知,你可以用

 sudo chmod 755 /usr

Edit

编辑

Folks, See my scripted solution over here.

伙计们,请在此处查看我的脚本解决方案。

回答by quido

I fixed this by using Disk Utility to repair disk permissions.

我通过使用磁盘工具修复磁盘权限解决了这个问题。

Open the Disk Utility application and select the disk your system is installed on. Then you can select "Repair Disk Permissions" from the First Aid tab. Repair will take a couple of minutes

打开磁盘实用程序应用程序并选择安装系统的磁盘。然后您可以从“急救”选项卡中选择“修复磁盘权限”。修复将需要几分钟

回答by Mikel

Executing the following worked for me on Mac OS X 10.11 El Capitan

在 Mac OS X 10.11 El Capitan 上执行以下对我有用

sudo chmod o-w /usr/local

sudo chmod o-w /usr/local

The error occured when loading a vagrant as follows;

加载一个vagrant时出现的错误如下;

vagrant status /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/pre-rubygems.rb:31: warning: Insecure world writable dir /usr/local in PATH, mode 040777 /opt/vagrant/embedded/gems/gems/bundler-1.10.6/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local in PATH, mode 040777 ls -dal /usr/local/ drwxrwxrwx 10 root wheel 340 Sep 9 15:05 /usr/local/

vagrant status /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/pre-rubygems.rb:31: warning: Insecure world writable dir /usr/local in PATH, mode 040777 /opt/vagrant/embedded/gems/gems/bundler-1.10.6/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local in PATH, mode 040777 ls -dal /usr/local/ drwxrwxrwx 10 root wheel 340 Sep 9 15:05 /usr/local/

After running the chmod mentioned above.

运行上述 chmod 后。

ls -dal /usr/local/ drwxrwxr-x 10 root wheel 340 Sep 9 15:05 /usr/local/

ls -dal /usr/local/ drwxrwxr-x 10 root wheel 340 Sep 9 15:05 /usr/local/

Which solved the problem.

这解决了这个问题。