I'v set sudo launchctl config user path PATH and now I cannot launch brew, npm, node and ect. from terminal. What I should to do for these commands work again from terminal?
Undo launchctl config user path PATH
If sudo launchctl config user path PATH
is the exact command you have run, then it appears you've set your user's path as the string PATH
.
When the above command is run, /private/var/db/com.apple.xpc.launchd/config/user.plist
is created.
$ cat /private/var/db/com.apple.xpc.launchd/config/user.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PathEnvironmentVariable</key>
<string>PATH</string>
</dict>
</plist>
To undo these changes, you can run defaults delete /private/var/db/com.apple.xpc.launchd/config/user.plist PathEnvironmentVariable
Alternatively you can do is run sudo launchctl config user path $PATH
to potentially restore launching all these applications. This will interpolate the value from the PATH
environment variable.
References:
- https://stackoverflow.com/a/70510488/399435
- https://apple.stackexchange.com/a/315876/12227