Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.66k stars 237 forks source link

brew doctor umask message a tiny bit misleading #907

Closed Almenon closed 5 years ago

Almenon commented 5 years ago

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.

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
sjackman commented 5 years ago

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

https://github.com/Linuxbrew/brew/blob/aed454897a835834a62ced40609b66d876a99904/Library/Homebrew/extend/os/linux/diagnostic.rb#L53-L62

Here's the definition of shell_profile:

https://github.com/Linuxbrew/brew/blob/aed454897a835834a62ced40609b66d876a99904/Library/Homebrew/utils/shell.rb#L38-L41

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.

sjackman commented 5 years ago

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