I could not find a way to globally disable the "Insecure world writable dir" warning.
Another answer suggests replacing the ruby executable with a shell script or to recompile ruby with different options. Both options are difficult and could lead to other unexpected problems, in my opinion.
However, I found a way to disable the warning for individual scripts/gems:
In my case, I use the gem colorls
to generate a nicer ls
output. So far, this gem is the only one the frequently triggers the warning. I solved it, by adding the following alias to my .zshrc
file (or .bash_profile
)
Solution 1
# Inside .zshrc
alias colorls='colorls --color=always 2>/dev/null'
The important part is the error redirection 2>/dev/null
.
Good: This alias allows me to add custom parameters to the command, like colorls --report
Bad: This alias will mask any error or warning that the command produces. I want to specifically remove the "Insecure world writable dir" warning.
Solution 2
# Inside .zshrc
alias colorls='colorls --color=always 2>&1 | grep "warning: Insecure world writable dir" -v'
Good: Instead of redirecting all errors to /dev/null
, my second attempt redirects all output to grep
, which strips out the individual warning message.
Bad: That solution does not recognize any colorls
parameters; any parameter will be passed to grep
instead of colorls
...
Solution 3 (best)
# Inside .zshrc
colorls() {
/usr/bin/colorls --color=always $@ 2>&1 | grep "warning: Insecure world writable dir" -v
}
This is the best solution: We replace the colorls
binary with a shell function. That shell function calls the binary. The $@
variable passes all parameters to the binary, while grep
removes the specific warning from the output.