在 PATH 中收到警告“Insecure world writable dir /home/chance”,rails 和 gem 模式为 040777

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

Getting the warning "Insecure world writable dir /home/chance " in PATH, mode 040777 for rails and gem

ruby-on-railsrubylinuxgemrvm

提问by Chance

I've tried thisbut it didn't work and seemed to be for osx. I have a fresh Ubuntu 10.10 install with rvm, rails 3 and ruby 1.9.2. I have a fresh rails app but using either gem or rails results in the following warnings (with lag).

我试过这个,但它没有用,似乎适用于 osx。我有一个带有 rvm、rails 3 和 ruby​​ 1.9.2 的全新 Ubuntu 10.10 安装。我有一个新的 rails 应用程序,但使用 gem 或 rails 会导致以下警告(有延迟)。

$ rails -v

$ 导轨 -v

/home/chance/.rvm/gems/ruby-1.9.2-p180@global/gems/railties-3.0.5/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /home/chance in PATH, mode 040777
/home/chance/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.10/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /home/chance in PATH, mode 040777
Rails 3.0.5


$ gem -v

$宝石 -v

/home/chance/.rvm/rubies/ruby-1.9.2-p180/bin/gem:4: warning: Insecure world writable dir /home/chance in PATH, mode 040777
1.6.2

Just incase it matters, here is my Gemfile:

以防万一,这是我的 Gemfile:

source 'http://rubygems.org'

gem 'rails'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem "haml"
gem "formtastic"
gem "will_paginate"
gem "devise"
gem "delayed_job"
gem "whenever"
gem "memcache-client"
gem "capistrano"
group :testing do
  gem "rspec"
  gem "rspec-rails"
  gem "autotest-standalone"
  gem "autotest-rails"
  gem "autotest-growl"
  gem "mocha"
  gem "shoulda"
  gem "factory_girl_rails"
end

group :development do
  gem "cheat"
  gem "bullet"
  gem "ruby-growl"

end

采纳答案by matt

If you tried sudo chmod go-w /usr/local/binfrom the other answer, try:

如果您尝试sudo chmod go-w /usr/local/bin过其他答案,请尝试:

chmod go-w /home/chance

instead.

反而。

What seems to have happened is that somehow your home directory (/home/chance) has been added to your $PATH(the list of directories the OS searches when trying to find an executable to launch) and has also had its permissions changed so that anyone can write to it. This is potential a security problem, as another user could put an executable into this directory which you could accidentally launch. Ruby notices this and issues the warning.

似乎发生的事情是,您的主目录 ( /home/chance)以某种方式添加到您的$PATH(操作系统在尝试查找要启动的可执行文件时搜索的目录列表)中,并且还更改了其权限,以便任何人都可以写入它。这是潜在的安全问题,因为另一个用户可能会将可执行文件放入您可能不小心启动的该目录中。Ruby 注意到这一点并发出警告。

This command changes the permissions of the directory so that it is no longer world writable.

此命令更改目录的权限,使其不再是全局可写的。

In unix, file permissions are specified for three categories, the file owner (user), the group of the file (group), and everyone else (other). (See Google for more on unix file permissions).

在 unix 中,文件权限被指定为三类,文件所有者(user)、文件所属的组(group)和其他所有人(other)。(有关 unix 文件权限的更多信息,请参阅 Google)。

So breaking down the command above:

所以分解上面的命令:

chmod- change the 'mode' of the file (i.e. its permissions)

chmod- 更改文件的“模式”(即其权限)

go- for group(g) and others(o)

go- 对于组(g)和其他(o)

-w- (minus w) remove write permission

-w- (减 w) 删除写权限

/home/chance- the file (or directory) in question

/home/chance- 有问题的文件(或目录)

In the other answer the directory that was causing the problem was /usr/local/bin, which is owned by root so sudois required to change permissions on it. /home/chanceis your home directory which is owned by the chanceuser who can change permissions on it - no sudorequired.

在另一个答案中,导致问题的目录是/usr/local/bin,该目录归 root 所有,因此sudo需要更改其权限。/home/chance是您的主目录,由chance可以更改其权限的用户拥有-sudo不需要。

回答by Pablo Marambio

I'm in a Mac, so /home/usernamedid not work for me. However, when I tried to changing permissions for /User/username, the error persisted.

我在 Mac 上,所以/home/用户名对我不起作用。但是,当我尝试更改/User/ username 的权限时,错误仍然存​​在。

The thing that got it working was chmod go-w /User/username/.rvm

让它工作的事情是 chmod go-w /User/username/.rvm

回答by Temo Dape

You use the chmod go-wto whatever path the terminal gives you.

你使用chmod go-w到终端给你的任何路径。

So if it says /usr/local as the path in the error message:

因此,如果它说 /usr/local 作为错误消息中的路径:

warning: Insecure world writable dir /usr/local in PATH, mode 040777

You write

你写

chmod go-w /usr/local

回答by bryanus

I had to use -R to fix mine:

我不得不使用 -R 来修复我的:

chmod -R go-w /Users/username

回答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​​ 存在于网络共享或某些此类上),请参阅此答案以了解抑制错误的方法

回答by Wazery

(If you are in a Mac) Try the option "Repair Disk Permissions" from the disk utility

(如果您使用的是 Mac)尝试磁盘实用程序中的“修复磁盘权限”选项

enter image description here

在此处输入图片说明

Probably a couple of lines in the details log will say:

详细信息日志中可能有几行会说:

Permissions differ on “usr”; should be drwxr-xr-x ; they are drwxrwxrwx.
Repaired “usr”