在 PATH 中获得警告“不安全的世界可写的 dir/home/chance”,Rails 和 gem 模式为040777

我试过 这个,但它不工作,似乎是为 osx。我有一个新的 Ubuntu10.10安装与 rvm,Rails 3和 Ruby 1.9。我有一个新鲜的 Rails 应用程序,但使用 gem 或 Rails 会导致以下警告(带延迟)。

$栏杆

/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

$宝石 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

以防万一,这是我的 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
79141 次浏览

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

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.

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).

So breaking down the command above:

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

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

-w - (minus w) remove write permission

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

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

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

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

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

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

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

You write

chmod go-w /usr/local

I had to use -R to fix mine:

chmod -R go-w /Users/username

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.

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

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”