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

zsh in CakeBrew doesn't find 'brew' command #65

Closed
jonphipps opened this issue Jun 5, 2014 · 17 comments
Closed

zsh in CakeBrew doesn't find 'brew' command #65

jonphipps opened this issue Jun 5, 2014 · 17 comments

Comments

@jonphipps
Copy link

In Cakebrew:

zsh:1: command not found: brew
Task finished at 2014-06-05 10:33 AM!

In terminal:

# jonphipps in ~ [10:34:17]
$ brew update
Updated Homebrew from c6d35b4d to 775680fb.
...
$ which brew
/usr/local/bin/brew
$ brew doctor
Your system is ready to brew.

In system log:

2014-06-05 10:32:34.937 AM Cakebrew[29826]: User shell: /usr/local/bin/zsh

OS X 10.8.5
Also all Formulae counts are 0.

@guillaume-ro-fr
Copy link

Same error on OS X 10.9 and zsh 5.0.2

@brunophilipe
Copy link
Owner

Have you changed your default shell using chsh? Using a different terminal or changing in the terminal properties doesn't change your default shell. Is it in the valid shells file /etc/shells?

@jonphipps
Copy link
Author

I believe that I changed it using the 'Advanced Options...' on my account in System Prefs, but the global nature of the effect is the same:

$ sudo dscl /Search -read "/Users/$USER" UserShell | awk '{print $2}'
/usr/local/bin/zsh

$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/zsh

I do note that zsh has two instances.

@brunophilipe
Copy link
Owner

Can you please paste the output of the command echo $SHELL;?

@jonphipps
Copy link
Author

$ echo $SHELL;
/usr/local/bin/zsh

@brunophilipe
Copy link
Owner

Can you please run the doctor on this debug build and paste the output here? It prints extra information from the environment variables.
http://www.cakebrew.com/files/Cakebrew_Debug_130.zip

@jonphipps
Copy link
Author

User Shell: /usr/local/bin/zsh
Command: /usr/local/bin/zsh -l -c brew doctor
The Doctor output is going to be different if run from Xcode!!

zsh:1: command not found: brew
Task finished at 2014-06-05 3:50 PM!

@brunophilipe
Copy link
Owner

I honestly don't know what else I can do. I know of people using Cakebrew with zsh set as their default shell. Please take a look on issue #44 because it seems similar to your issue.

@jonphipps
Copy link
Author

one thing from that issue: "Actually what the app does is find out the used shell, check if it is present in the /etc/shells (you can add it there manually), call the used shell with the arguments -l -c echo $PATH; echo $HOME; and grab the output. "

$ /usr/local/bin/zsh -l -c echo $PATH;

does not produce any output on my system
but... CakeBrew seems to work correctly (!) when launched like so:

$ sudo /Applications/Cakebrew.app/Contents/MacOS/Cakebrew

although 'brew doctor' in CakeBrew complains:

$rvm_path (/usr/local/rvm) does not exist.Your system is ready to brew.
Task finished at 2014-06-05 4:50 PM!

@guillaume-ro-fr
Copy link

With me and without the sudo mode, Cakebrew can update the brew database and any formula but I can't launch brew doctor. The log :

User Shell: /bin/zsh
Command: /bin/zsh -l -c brew doctor
The Doctor output is going to be different if run from Xcode!!
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    bashbug
    node
    phar
    phar.phar
    php
    php-config
    phpize

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
    echo export PATH='/usr/local/sbin:$PATH' >> ~/.bash_profile
Task finished at 05/06/2014 23:11! 

I have executed this command but it's change nothing :
/bin/zsh -l -c echo $PATH;

@neoesque
Copy link

According to zsh guide http://zsh.sourceforge.net/Guide/zshguide02.html the login shell start up files are ~/.zprofile and ~/.zlogin
so I think all the zsh user who's cakebrew cannot find brew should put the following line into ~/.zlogin (or ~/.zprofile)
export PATH=/usr/local/bin:$PATH
(/usr/local/bin can be replaced with your brew's directory)
this works for me. (I only have ~/.zshrc in the begining)

@brunophilipe
Copy link
Owner

Thank you very much for this information. I think I will need to create a wiki for people to setup their zsh shells properly...

@bezigon
Copy link

bezigon commented Jul 11, 2014

Related problem with zsh, while trying to upgrade brew formulaes in Cakebrew: zsh:1: parse error near )'`
Solution?

@brunophilipe
Copy link
Owner

@bezigon This is a duplicate of issue #71 :)

@brunophilipe
Copy link
Owner

Closing as this issue is a month old and the OP didn't come back with updated info.

@gwerbin
Copy link

gwerbin commented Oct 14, 2017

Not sure if this is still an issue, but hopefully I can shed some light on where to look for solutions.

OSX/MacOS (at least since 10.9 when I switched from Windows 🙊) ships with the following /etc/zprofile:

# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
	eval `/usr/libexec/path_helper -s`
fi

As described here and in the man page for path_helper(1), the command path_helper -s generates a Bash script that:

  1. adds the contents of /etc/paths and /etc/manpaths to PATH
  2. iterates over files in /etc/paths.d and /etc/manpaths.d, appending the contents of each to PATH
  3. exports PATH

which can then be evaled by the shell.

Startup files are loaded in this order: zshenv, zprofile, zshrc, and finally zlogin. /etc/zshenv is loaded first no matter what. Then, if the GLOBAL_RCS option is set (which it is by default) /etc is searched for these files. Then if the RCS option is set (also "on" by default), $ZDOTDIR, or $HOME if ZDOTDIR is unset. /zshenv is always loaded; zprofile and zlogin are loaded only for login shells, and zshrc is loaded only for interactive shells.

So these are the files that are being loaded by Cakebrew, if Cakebrew is in fact opening a non-interactive login shell:

  1. /etc/zshenv; missing by default
  2. /etc/zprofile; the path_helper stuff is here by default
  3. /etc/zlogin; missing by default
  4. ${ZDOTDIR:-HOME}/zshenv
  5. ${ZDOTDIR:-HOME}/zprofile
  6. ${ZDOTDIR:-HOME}/zlogin

It seems like @jonphipps and the user in #107 have issues in one of these files, or in /etc/paths, /etc/paths.d, /etc/manpaths, /etc/manpaths.d.

@aubreypwd
Copy link

Adding:

export PATH="/opt/homebrew/bin:$PATH"

...to $HOME/.zlogin made Cakebrew work for me. I had my $PATH setup in .zshrc but it still failed to load, I guess Cakebrew just doesn't catch the .zshrc file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants