0

I remember that I used brew some time ago. But now when I try to run it I get

➜  ~ brew      
zsh: command not found: brew

but there is an alias /usr/local/bin/brew which I can run. Also it's location is in my PATH variable:

➜  ~ echo $PATH
/Users/kosh/.rvm/gems/ruby-3.0.2/bin:/Users/kosh/.rvm/gems/ruby-3.0.2@global/bin:/Users/kosh/.rvm/rubies/ruby-3.0.2/bin:/usr/local/opt/gradle@6/bin:”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/kosh/Documents/Development/flutter/bin:/Users/kosh/.rvm/bin://Users/kosh/Library/Android/sdk/tools://Users/kosh/Library/Android/sdk/tools/bin://Users/kosh/Library/Android/sdk/platform-tools”

Why is it happening? How can I fix it?

As a shell I use Oh My Zsh.

0

1 Answer 1

1

Hypothesis: somewhere in your startup scripts there is something like:

PATH=/usr/local/opt/gradle@6/bin:”$PATH”

which should be like:

PATH=/usr/local/opt/gradle@6/bin:"$PATH"

At this point your $PATH expanded to /usr/local/bin:…. Because curly quotes are not special to the shell, they are not removed during quote removal phase. In effect they literally appeared in your new $PATH.

In the $PATH you posted, the entry most similar to /usr/local/bin is ”/usr/local/bin which is not /usr/local/bin. Similarly //Users/kosh/Library/Android/sdk/platform-tools” is not //Users/kosh/Library/Android/sdk/platform-tools.

Some websites change regular quotes to curly quotes, because apparently their purpose it to hold literature or any non-technical text (where curly quotes look nice), not code. IMO such behavior is an indication the site is not a good source of any code. Maybe you have copied from such site.

Or maybe you have edited one of your startup scripts in a text editor that "knows better" and changes regular quotes to curly quotes.

You should review every script that adds to your $PATH, find these curly quotes and fix them (change to regular double-quotes). And never use curly quotes in shell scripting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .