zsh problems MacOS High Sierra

raf macports at raf.org
Tue May 3 09:32:35 UTC 2022


On Mon, May 02, 2022 at 11:22:35AM -0400, Jean Bermudez <etereocode at gmail.com> wrote:

> Hi there!
> 
> I installed "NeoVim" and "zsh" via MacPorts on MacOs High Sierra.
> 
> I have a problem. High Sierra comes with "zsh" version 5.3 installed by
> default. I noticed this after I installed zsh version 5.8.1 via MacPorts.
> 
> How did I figure it out?
> - I changed the default shell (bash) to "zsh" via the command "chsh -s
> /bin/zsh".
> - I tried to start NeoVim with the command "nvim".
> - And the system responded "zsh: command not found: nvim".
> - After trying several things, I entered the command "zsh -version" and the
> version that was active was 5.3 (High Sierra).
> - I went back to the "bash" shell and simply entered the command "zsh" to
> use the zsh shell, and when I checked the version (zsh -version) the
> version was 5.8.1 (MacPorts). I entered the command "nvim" and it worked.
> 
> I got desperate looking for a solution and entered several times the
> command you provide on your site to set MacPorts': sudo sh -c 'echo
> ${prefix}/bin/zsh >>/etc/shells'.
> 
> Now when I check the list of Shells with "cat /etc/shells". I get
> "/bin/zsh" four times.
> 
> I want to delete all zsh and install only the MacPorts "zsh" cleanly; and
> then set that shell to default.
> 
> How do I do this?

I'd recommend leaving /bin/zsh where it is, adding
/opt/local/bin/zsh to /etc/shells and setting your
shell to that with chsh. Then, make sure that
/opt/local/bin is before /bin in your $PATH.

If that doesn't do it, because no matter what you try,
the PATH doesn't get set to what you want, the problem
might be caused by the use of /usr/libexec/path_helper
in /etc/zprofile.

I think it's Apple's way of trying to be helpful by
assuming that you don't know what you want your own
$PATH to be. By default, that file looks something
like:

  if [ -x /usr/libexec/path_helper ]; then
      eval `/usr/libexec/path_helper -s`
  fi

Get it to echo $PATH before and after path_helper to
see if you want what it's doing. If not, change it to
stop path_helper from running.

Mine looks like:

  if [ $(id -un) != raf ]; then
      if [ -x /usr/libexec/path_helper ]; then
          eval `/usr/libexec/path_helper -s`
      fi
  fi

Having said all that, be warned that it might be
dangerous to set your default shell to a macports
shell, because when upgrading from one major macos
version to another, you might not have a functioning
macports system (since you need to remove and reinstall
macports). I'm not sure that that's a problem, but it
sounds like it probably is. So you might want to chsh
your shell back to /bin/zsh before a major upgrade, and
chsh it back to /opt/local/bin/zsh afterwards. But I've
never had to do that, so maybe it's not a problem.

cheers,
raf



More information about the macports-users mailing list