macoshomebrewmacos-high-sierraxcode-command-line-tools

Replacing old Xcode command line tool with newer Brew version


I'm trying to build a binary from source code which has a dependency on the package" NASM 2.12.02 or later. However, I have an earlier version already installed on my Mac via Xcode:

/usr/local/bin/nasm -v
    NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on May  1 2018

So to (attempt to) rectify this, I used Homebrew to install a much newer version of the package

brew info nasm
    nasm: stable 2.13.03 (bottled), HEAD

However, now my PATH is only pointed to the old NASM executable, while the new tool seems to be sitting in Homebrew's Cellar (ie. /usr/local/Cellar/nasm/2.13.03).

Is there a nice way of "switching" between these versions so that the system PATH views only the newer version and disregards the older one? So far I've thought of rm -rf-ing the old version and exporting the new version to my PATH, but that seems very destructive.

Also, I have run the command: brew doctor and have resolved all linker errors, but that has not seemed to help.

Any help would be greatly appreciated!


Solution

  • To fix this, I used the following command:

    export PATH=/usr/local/Cellar/nasm/2.13.03/bin:$PATH
    

    This modifies the PATH variable to point to the /usr/local/Cellar/nasm/2.13.03/bin directory and find the nasm executable there before looking in /usr/local/bin.