bash – Strange “command not found” and “No such file or directory” errors

Very strange errors of multiple forms:

  1. Running brew install c-ares fails with command not found, seemingly not even executing brew:
    $ brew install c-ares
    -bash: brew install c-ares: command not found
    

    Yet brew install cmake executes brew as expected:

    $ brew install cmake
    Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
    Warning: cmake 3.25.1 is already installed and up-to-date.
    To reinstall 3.25.1, run:
      brew reinstall cmake
    
  2. Cannot prepend /usr/local/opt/qt5/bin to $PATH with the error No such file or directory:
    $ export PATH=/usr/local/opt/qt5/bin:$PATH
    -bash: export PATH=/usr/local/opt/qt5/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin: No such file or directory
    

    That folder does exist:

    $ [ -d /usr/local/opt/qt5/bin ] && echo "exists"
    exists
    

    As do all the others on $PATH:

    $ echo $PATH
    /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin
    $ for i in $(echo $PATH | awk -F: '{for (i=1; i<=NF; i++) { print $i; }}'); do if [ -d "$i" ]; then echo "$i exists"; else echo "$i does not exist"; fi; done
    /usr/local/bin exists
    /System/Cryptexes/App/usr/bin exists
    /usr/bin exists
    /bin exists
    /usr/sbin exists
    /sbin exists
    /Library/TeX/texbin exists
    /usr/local/MacGPG2/bin exists
    /opt/X11/bin exists
    /Library/Apple/usr/bin exists
    

    Yet adding /tmp works:

    $ export PATH=/tmp/:$PATH
    $ echo $PATH
    /tmp/:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin
    
  3. Same errors with zsh:
    $ zsh
    % brew install c-ares
    zsh: command not found: brew install c-ares
    % brew install cmake
    Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
    Warning: cmake 3.25.1 is already installed and up-to-date.
    To reinstall 3.25.1, run:
      brew reinstall cmake
    % export PATH=/usr/local/opt/qt5/bin:$PATH
    zsh: no such file or directory: export PATH=/usr/local/opt/qt5/bin:/tmp/:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin
    

I’m quite baffled and don’t know how to debug shell built-ins.

Nothing comes to mind of what recently changed that could cause this. I upgraded to Ventura 13.1 today hoping this would go away, but it was happening before the upgrade and continues to happen.

I tried restarting and it didn’t help.

System information:

% system_profiler SPSoftwareDataType SPHardwareDataType | grep -v -e UUID -e UDID -e 'User Name' -e 'Computer Name' -e Serial
Software:

    System Software Overview:

      System Version: macOS 13.1 (22C65)
      Kernel Version: Darwin 22.2.0
      Boot Volume: MainDisk
      Boot Mode: Normal
      Secure Virtual Memory: Enabled
      System Integrity Protection: Disabled
      Time since boot: 22 minutes, 2 seconds

Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro15,1
      Processor Name: 6-Core Intel Core i7
      Processor Speed: 2.6 GHz
      Number of Processors: 1
      Total Number of Cores: 6
      L2 Cache (per Core): 256 KB
      L3 Cache: 9 MB
      Hyper-Threading Technology: Enabled
      Memory: 16 GB
      System Firmware Version: 1916.60.2.0.0 (iBridge: 20.16.2059.0.0,0)
      OS Loader Version: 564.40.4~55
      Activation Lock Status: Enabled

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: