87

I've tried this but 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).

$ rails -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

/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:

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
Community
  • 1
  • 1
Chance
  • 11,043
  • 8
  • 61
  • 84
  • I also have a bounty on http://stackoverflow.com/questions/5360327/installed-ruby-on-rails-but-when-i-try-to-run-rails-sever-it-doenst-load-webrick if its the same solution. My server will actually start so I didn't know if it was the same problem. (Im a *nix newb) – Chance Mar 21 '11 at 16:43
  • 1
    When you said you tried the answer from the other question, did you just use the command suggested there: `sudo chmod go-w /usr/local/bin`? If so try `chmod go-w /home/chance` instead. – matt Mar 21 '11 at 18:24
  • matt, can you actually answer with that? it was a stupid question but /usr/local/bin failed silently so i thought the chmod went through. Thanks man. – Chance Mar 22 '11 at 04:36
  • possible duplicate of [warning Insecure world writable dir](http://stackoverflow.com/questions/3952243/warning-insecure-world-writable-dir) – kenorb Sep 20 '14 at 09:44
  • Im getting the above error for /usr/lib - And can't even perform chmod go-w as no permission for Any user other than Root. For certain reasons, I can't enter Root. Hence what's the solution now other than ignoring? – Chaitanya Bapat Mar 17 '17 at 20:15

6 Answers6

193

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.

matt
  • 78,533
  • 8
  • 163
  • 197
  • On my `Lubuntu 16.04` having the warning: `Insecure world writable dir /tmp/. in PATH, mode 041777` was also causing an infinite looping on the warning. I then executed the `sudo chmod go-w /tmp` command and it solved the issue. – Stephane Sep 09 '18 at 19:17
40

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
Temo Dape
  • 401
  • 4
  • 2
23

I had to use -R to fix mine:

chmod -R go-w /Users/username
bryanus
  • 954
  • 1
  • 8
  • 11
  • Do not run with sudo unless you know what you are doing! (you have checked permissions of every folder within) – qwr Dec 05 '19 at 22:23
9

(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”
nacho4d
  • 43,720
  • 45
  • 157
  • 240
Wazery
  • 15,394
  • 19
  • 63
  • 95
  • 4
    The question is tagged Linux, not Mac. However this thread was the first Google hit, and I'm on a Mac, so this worked for me! [Canonical Mac answer to the same question here](http://stackoverflow.com/a/23271756/62269). – Bluu May 22 '14 at 23:45
5

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

Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62
Pablo Marambio
  • 1,562
  • 1
  • 15
  • 29
3

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.

Community
  • 1
  • 1
Connor McKay
  • 580
  • 7
  • 13