ohmyzsh: Changing `$PATH` after `gnu-utils` plugin has loaded breaks functionality

Describe the bug

Hello,

I have a problem on macOS with gnu-utils plugin. It works fine with this minimal .zshrc file:

export ZSH="/Users/test/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(
gnu-utils
)
source $ZSH/oh-my-zsh.sh

But, when I add the pyenv plugin, gnu-utils plugin seems to break. Minimal non-working .zshrc file:

export ZSH="/Users/test/.oh-my-zsh"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
ZSH_THEME="robbyrussell"
plugins=(
gnu-utils
pyenv
)
source $ZSH/oh-my-zsh.sh

Demonstration:

➜  ~ mkdir -v test
mkdir: created directory 'test'
➜  ~ rm test -rfv
rm: test: is a directory
rm: -rfv: No such file or directory
➜  ~ rm -rfv test
test

Steps to reproduce

Enable gnu-utils and pyenv plugin.

Run the following commands:

➜  ~ mkdir -v test
mkdir: created directory 'test'
➜  ~ rm test -rfv
rm: test: is a directory
rm: -rfv: No such file or directory

Expected behavior

Gnu version of rm should be used, and the -rfv args must be accepted at the end of the line.

Screenshots and recordings

No response

OS / Linux distribution

macOS 11.6

Zsh version

5.8

Terminal emulator

iTerm2

If using WSL on Windows, which version of WSL

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I solved the issue by reassigning the GNU utils on every command execution, if they aren’t already assigned. You should be good to go now if you omz update.

@ardeidae I can’t reproduce your problem in macOS 10.15. You could generate a trace of the zsh initialization (with the configuration that makes the plugin fail) and post it here. You can do that with zsh -xvic exit &> ~/omz-debug.log.

Not that this will contain sensitive info like the user and host names. If you prefer, you can email it to me at marc@ohmyz.sh.