Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linuxbrew install steps don't add brew to PATH #6033

Closed
1 task done
cefn opened this issue Apr 18, 2019 · 9 comments
Closed
1 task done

Linuxbrew install steps don't add brew to PATH #6033

cefn opened this issue Apr 18, 2019 · 9 comments
Assignees
Labels
outdated PR was locked due to age

Comments

@cefn
Copy link

cefn commented Apr 18, 2019

  • are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh

Later checks don't apply as the path to brew is broken when following the install instructions.

What you were trying to do (and why)

Follow the install instructions at https://github.com/Homebrew/brew/blob/master/docs/Homebrew-on-Linux.md to get brew installed and on my path on an Ubuntu Bionic laptop. Test: interactively launching a GUI terminal such as LXTerminal or Gnome Terminal should be able to run a brew binary.

What happened (include command output)

Typing brew from a new terminal gets me...

Command output
  
cefn@cefn-dell-bionic:~$ brew 
Command 'brew' not found, but can be installed with:
sudo apt install linuxbrew-wrapper  
  

What you expected to happen

Homebrew would be found in my PATH from a newly-launched LXTerminal after following the shell profile configuration instructions.

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

For Ubuntu/Debian I believe the instructions should be to add a command like

eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

to ~/.bashrc not ~/.bash_profile or ~/.profile See e.g. https://what.thedailywtf.com/topic/19866/bash_profile-vs-bashrc-ubuntu

See https://github.com/Homebrew/brew/blob/deffe8d403ff092c04b92094635eb8006c8f3bdf/docs/Homebrew-on-Linux.md for the currently broken instructions which reference only .bash_profile for Ubuntu/Debian and this approach would only work for the case of relaunching in a login shell.

@cefn
Copy link
Author

cefn commented Apr 18, 2019

This probably explains #5872

@MikeMcQuaid MikeMcQuaid assigned sjackman and iMichka and unassigned sjackman Apr 19, 2019
@sjackman
Copy link
Member

@Homebrew/linux Two options here:

  1. Modify ~/.bash_profile and instruct the user to log out and log back in
  2. Modify ~/.bashrc rather than ~/.bash_profile

@cefn
Copy link
Author

cefn commented Apr 19, 2019

I feel number 2) modify .bashrc is preferred.

That's because .bashrc is evaluated in .bash_profile anyway, and avoids someone having to restart their desktop.

@iMichka
Copy link
Member

iMichka commented Apr 19, 2019

Actually there is something in the install instructions:
https://github.com/Linuxbrew/install/blob/master/install#L486-L489

I think these are more up-to-date. We should align the documentation in https://github.com/Homebrew/brew/blob/deffe8d403ff092c04b92094635eb8006c8f3bdf/docs/Homebrew-on-Linux.md to reflect that.

@sjackman
Copy link
Member

sjackman commented Apr 19, 2019

- Configure Linuxbrew in your #{Tty.underline}#{shell_profile}#{Tty.reset} by running
    echo 'eval $(#{HOMEBREW_PREFIX}/bin/brew shellenv)' >>#{shell_profile}
- Add Linuxbrew to your #{Tty.bold}PATH#{Tty.reset}
    eval $(#{HOMEBREW_PREFIX}/bin/brew shellenv)

These instructions fix the current shell. On Ubuntu, if the user opens a new shell, that shell will not work (will not have Homebrew in PATH). Once the user logs out and logs back in, all shells will work.

@cefn
Copy link
Author

cefn commented Apr 21, 2019

For the time being there's a straight-up factual inaccuracy in the documentation...

You're done! Try installing a package:
brew install hello

This is not true, brew will not be available after placing these commands in .bash_profile.

I am surprised you prefer to put brew-specific shell config into .profile or .bash_profile and not .bashrc for Ubuntu/Debian/Others, which would eliminate the issues. However, if you're going with this choice, it should be stated that a full restart of the desktop is needed before brew will be available.

Currently your new Ubuntu and Debian users will be hitting a brick wall following these instructions, and will assume they have made an error or have something shonky about their config given the clear statement that these steps should make brew available when they just don't.

@sjackman
Copy link
Member

This is not true, brew will not be available after placing these commands in .bash_profile.

- Configure Linuxbrew in your #{Tty.underline}#{shell_profile}#{Tty.reset} by running
    echo 'eval $(#{HOMEBREW_PREFIX}/bin/brew shellenv)' >>#{shell_profile}
- Add Linuxbrew to your #{Tty.bold}PATH#{Tty.reset}
    eval $(#{HOMEBREW_PREFIX}/bin/brew shellenv)

Following these instructions, which are printed by the installer, will add Homebrew to the PATH in the current shell, after which brew install hello will work. The first command adds it to the shell profile, the second adds it to the PATH of the current shell.

@cefn
Copy link
Author

cefn commented Apr 22, 2019

Good point. Still unsure why the decision has been to add to .bash_profile but I was factually wrong for the shell which the user actually ran the install in. You are right, the proper environment will have been set up for that shell session alone.

The choice of .bash_profile instead of .bashrc means it won't be available in another shell until the desktop is restarted on Ubuntu/Debian. To a non-specialist user it may seem the brew installation has disappeared when running from a different shell or if they close and reopen a terminal without memorising the eval step.

To my mind is a POLA violation https://en.wikipedia.org/wiki/Principle_of_least_astonishment and is most likely responsible for #5872 but you know much more about the constraints of installing across multiple target platforms so you probably have good reason. Happy to close.

@cefn cefn closed this as completed Apr 22, 2019
@sjackman
Copy link
Member

@Homebrew/linux Two options here:

  1. Modify ~/.bash_profile and instruct the user to log out and log back in
  2. Modify ~/.bashrc rather than ~/.bash_profile

@lock lock bot added the outdated PR was locked due to age label May 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

3 participants