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

Solution 1:

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.

Solution 2:

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

Solution 3:

I had to use -R to fix mine:

chmod -R go-w /Users/username

Solution 4:

(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”