Linuxbrew/brew

brew doctor umask message a tiny bit misleading

Almenon opened this issue · 2 comments

Please note that we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • ran a brew command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Linuxbrew/homebrew-core: https://github.com/Linuxbrew/homebrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Fix umask as reported by brew doctor

Warning: umask is currently set to 000. Directories created by Homebrew cannot
be world-writable. This issue can be resolved by adding umask 002 to
your ~/.bash_profile
echo 'umask 002' >> ~/.bash_profile

What happened (include command output)

Executed the suggested command:

echo 'umask 002' >> ~/.bash_profile

This created a ~/.bash_profile file. Unbeknownst to me the bash_profile overrides my .profile file, causing my aliases to dissapear among everything else in the .profile. At first I was baffled untill I realized what was going on.

What you expected to happen

I would've expected the suggested command to work for both bash_profile and profile, like so:

[[ -f .bash_profile ]] && echo 'umask 002' >> ~/.bash_profile || echo 'umask 002' >> ~/.profile

Step-by-step reproduction instructions (by running brew commands)

  1. Install ubuntu on windows
  2. Install brew following steps on website
  3. brew doctor. Because of a outstanding bug with ubuntu on windows the umask is not set correctly, so doctor will tell you to set the umask.
  4. echo 'umask 002' >> ~/.bash_profile

I agree that it shouldn't do that. Here's the relevant function check_umask_not_zero which calls shell_profile.

def check_umask_not_zero
return unless File.umask.zero?
<<~EOS
umask is currently set to 000. Directories created by Homebrew cannot
be world-writable. This issue can be resolved by adding umask 002 to
your #{shell_profile}
echo 'umask 002' >> #{shell_profile}
EOS
end

Here's the definition of shell_profile:

# return the shell profile file based on user's preferred shell
def profile
SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
end

When preferred is bash, it should return ~/.bash_profile if it exists, and if not ~/.profile.

Would you like to submit a PR to https://github.com/Homebrew/brew/ ?

Note that Linuxbrew/brew is being merged into Homebrew/brew.

This issue is a recognized bug, but I'm closing this issue, since no one is actively working on it.