tl;dr
Goal: Easily download zip file with a console app (and other files), execute it, and later replace it with updated version.
Details
When I want to download a console app, with a command-line interface, into what appropriate folder should I place it? I want the tool to be automatically present on the PATH.
I am not referring to the Apple developer tools from Xcode. I am asking about third-party tools such as Microsoft Kiota.
From what little I know about other Unix-oriented operating systems such as FreeBSD, /opt
is the usual place for added third-party apps not controlled by the OS. I added a /opt
to my macOS Sonoma 14.4.1 machine. I can explicitly run the console app from there. But that location does not seem to be on the PATH automatically.
I tried /usr/local
and /usr/local/bin
. But no go. Executing kiota --version
results in "kiota not found".
I found /usr/local/bin
existing on my Mac. Several exiting items are found there, all related to Docker (presumably from my install of Docker Desktop app). All of those items are reported by the Finder.app as being "Alias", though I suspect they are actually symlinks. Using "Show original" in the Finder for those Docker items takes me to a folder nested within the GUI Mac app Docker.app. Placing my Kiota folder hierarchy within usr/local/bin
does not result in putting kiota
on the default PATH in Terminal.app, even after a system restart.
Workarounds
One workaround is to give up on the convenience of PATH. Drag and drop the kiota
from any folder into the Terminal.app window. The tool then executes successfully:
/usr/local/Kiota/osx-arm64/kiota --version
1.14.0+fc4b39c65d89f7bfc8c7f1813c197e95e206da09
(1.14.0 is indeed expected, and correct.)
Another workaround is to manually add to the values within the PATH
environment variable. But… the entire point of my Question is to avoid manipulating the PATH explicitly. As far as I know, all other Unix-oriented OSes such as BSD & Linux offer a default place for third-party console apps. I would expect the same in macOS.
Non-workarounds
Putting an alias (File > Make Alias
in the Finder) of the kiota
executable into /usr/local/bin does not work, even after system restart. which kiota
results in "kiota not found".
brew install kiota
on Intel Monterey,/usr/local/bin/kiota
was created as a symbolic link to../Cellar/kiota/1.11.1/bin/kiota
, which is a bash script. This script contains the line#!/bin/bash
followed by the lineDOTNET_ROOT="${DOTNET_ROOT:-/usr/local/opt/dotnet/libexec}" exec "/usr/local/Cellar/kiota/1.11.1/libexec/kiota" "$@"
.