brew: Assuming wrong shell in .profile
Please note 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
brew updateand can still reproduce the problem? - ran
brew doctor, fixed all issues and can still reproduce the problem? - ran
brew configandbrew doctorand included their output with your issue?
What you were trying to do (and why)
Add Homebrew to my PATH as suggested by the docs
What happened (include command output)
set: -g: invalid option (more extensive but not relevant in my opinion as the issue is known)
What you expected to happen
It adds it to my PATH
Step-by-step reproduction instructions (by running brew commands)
- Use GNOME
- Set
fishas your default shell, possibly making sure$SHELLis fish. - Run
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.profile(in Bash) - Log out and back in
- Notice
.profileerror
Output of brew config and brew doctor commands
$ brew config HOMEBREW_VERSION: 2.4.5 ORIGIN: https://github.com/Homebrew/brew HEAD: 6d2c39579e22d0ee9baccdccdd8a12efb8b00304 Last commit: 4 hours ago Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core Core tap HEAD: 5c3e01d57e4bb18d4b338b6893800cfaa65bc197 Core tap last commit: 50 minutes ago HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew HOMEBREW_DISPLAY: :0 HOMEBREW_MAKE_JOBS: 8 CPU: octa-core 64-bit haswell Homebrew Ruby: 2.6.3 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/bin/ruby Clang: N/A Git: 2.27.0 => /bin/git Curl: 7.68.0 => /usr/bin/curl Kernel: Linux 5.4.0-40-generic x86_64 GNU/Linux OS: Ubuntu 20.04 LTS (focal) Host glibc: 2.31 /usr/bin/gcc: 9.3.0 glibc: N/A gcc: N/A xorg: N/A $ brew doctor Your system is ready to brew.
Additional Context
GNOME sources ~/.profile on login. I believe this is always with Bash and is not affected by the login shell.
Output of ps --forest:
PID TTY TIME CMD
23877 tty2 00:00:00 gdm-x-session
23879 tty2 00:00:00 \_ Xorg
23903 tty2 00:00:00 \_ Xsession
23908 tty2 00:00:00 \_ ps
It seems brew shellenv is impacted by $SHELL, and returns Fish env vars setup code.
Output:
$ brew shellenv
set -gx HOMEBREW_PREFIX "/home/linuxbrew/.linuxbrew";
set -gx HOMEBREW_CELLAR "/home/linuxbrew/.linuxbrew/Cellar";
set -gx HOMEBREW_REPOSITORY "/home/linuxbrew/.linuxbrew/Homebrew";
set -q PATH; or set PATH ''; set -gx PATH "/home/linuxbrew/.linuxbrew/bin" "/home/linuxbrew/.linuxbrew/sbin" $PATH;
set -q MANPATH; or set MANPATH ''; set -gx MANPATH "/home/linuxbrew/.linuxbrew/share/man" $MANPATH;
set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH "/home/linuxbrew/.linuxbrew/share/info" $INFOPATH;
This also happens in .profile as SHELL is set to Fish, however, as .profile is sourced with Bash, eval $(brew shellenv) errors as the returned commands are for Fish. A workaround:
$ SHELL=bash brew shellenv
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH}";
As this is not included in the docs, maybe shellenv should detect if it is running part of this GNOME source or use a different way of detecting the shell as using SHELL is not accurate in this context. If this wasn’t added then maybe a warning in the docs should be included explaining this.
Full workaround:
Run echo "eval \$(SHELL=/bin/bash $(brew --prefix)/bin/brew shellenv)" >> ~/.profile instead (in Bash)
Workaround part of first installation (replacement for docs):
> bash
$ test -d ~/.linuxbrew && eval $(SHELL=/bin/bash ~/.linuxbrew/bin/brew shellenv)
$ test -d /home/linuxbrew/.linuxbrew && eval $(SHELL=/bin/bash /home/linuxbrew/.linuxbrew/bin/brew shellenv)
$ test -r ~/.bash_profile && echo "eval \$(SHELL=/bin/bash $(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
$ echo "eval \$(SHELL=/bin/bash $(brew --prefix)/bin/brew shellenv)" >>~/.profile
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (12 by maintainers)
@nihaals unless you have
HOMEBREW_DEVELOPERset you will not see this change until a new tag is released.