警告:当我运行 ruby​​ 或 gem 命令时,世界可写目录不安全

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

warning: Insecure world writable dir when I run a ruby or gem command

ruby-on-railsmacosrubygemsosx-snow-leopard

提问by Trip

Not sure why I'm getting this, but I just installed RVM, the new Ruby 1.9, and reinstalled a bunch of gems, and I get this

不知道为什么我会得到这个,但我刚刚安装了 RVM,新的 Ruby 1.9,并重新安装了一堆 gem,然后我得到了这个

/Users/johnsmith/.rvm/rubies/ruby-1.9.1-p378/bin/gem:4: warning: Insecure world writable dir /opt/local/bin in PATH, mode 040777

/Users/johnsmith/.rvm/rubies/ruby-1.9.1-p378/bin/gem:4:警告:不安全的世界可写目录 /opt/local/bin 在 PATH,模式 040777

Everything still runs otherwise, but I was wondering if there was a way I could get rid of it.

一切仍然以其他方式运行,但我想知道是否有办法摆脱它。

回答by Alex Martelli

Just chmod go-w /opt/local/binat a shell prompt (depending on permissions you may need to sudoto do that).

只是chmod go-w /opt/local/bin在 shell 提示符下(取决于您可能需sudo要这样做的权限)。

回答by jstreebin

To clarify, whatever path returns after it says insecure world writeable, is what you use.

澄清一下,在说不安全的世界可写之后返回的任何路径都是您使用的。

So instead of: chmod go-w /opt/local/bin you would replace /opt/local/bin with whatever your path is.

因此,不是: chmod go-w /opt/local/bin 你可以用你的路径替换 /opt/local/bin 。

回答by Siddhartha Mukherjee

Find your gem path so we can edit the bundler gem. Execute the following in your shell:

找到您的 gem 路径,以便我们可以编辑 bundler gem。在你的 shell 中执行以下命令:

$ ruby -r rubygems -e "p Gem.path"

Navigate to your gem path and cd into the version of bundler currently being used. Now navigate to lib -> bundler and open runtime.rb in your favorite text editor. Add “$VERBOSE = nil” to line 2.

导航到您的 gem 路径,然后 cd 进入当前使用的 bundler 版本。现在导航到 lib -> bundler 并在您喜欢的文本编辑器中打开 runtime.rb。将“$VERBOSE = nil”添加到第 2 行。

require "digest/sha1" 
$VERBOSE = nil 
module Bundler   
class Runtime < Environment
    include SharedHelpers

    def setup(*groups)
      # Has to happen first
      clean_load_path

...

...

回答by iGbanam

In some cases (like mine), the stack goes deeper than opt/local/bin. In that case, use

在某些情况下(比如我的),堆栈比opt/local/bin. 在这种情况下,请使用

sudo chmod go-w opt/local/*/bin usr/local/*/bin opt/local/bin usr/local/bin

In any case, the error prompts where the insecure world is.

无论如何,错误提示不安全的世界在哪里。

回答by Connor McKay

If your environment does not allow you to fix this error properly (i.e. ruby lives on a network share or some such), see this answer for a way to suppress the error.

如果您的环境不允许您正确修复此错误(即 ruby​​ 存在于网络共享或某些此类上),请参阅此答案以了解抑制错误的方法