Tag Archives: macOS

Global Homebrew PATH Prefix for macOS

Based on Homebrew’s FAQ you can set prefix in PATH for all GUI apps which is not enabled by default:

user$ sudo launchctl config user path "$(brew --prefix)/bin:${PATH}"
Configuration applied. You must reboot for changes to take effect.

According to this answer. The sudo launchctl config user path <...> command updates /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>/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</plist>

You can query launchd‘s current settings via:

launchctl getenv PATH

Related: You can also query the default PATH by executing:

sysctl user.cs_path

Test script with clear environment:

env -i git commit

Remove/Uninstall Rosetta 2 from Apple Silicon Macs

  1. Obtain a list of files/directories and LaunchAgents with: pkgutil --files com.apple.pkg.RosettaUpdateAuto
  2. Save them in a way that you can access them in the recovery
  3. Boot into recovery mode: Press and hold the power button on your Mac until “Loading startup options” appears.
  4. Open Terminal in recovery mode
  5. Run csrutil disable and confirm (temporary disable SIP)
  6. Reboot
  7. Delete the files listed at step 1 (in my case it was enough to delete /Library/Apple/usr/share/rosetta and /Library/Apple/usr/libexec with all their contents)
  8. Remember to empty the Trash
  9. Reboot back to recovery
  10. Run csrutil enable and confirm

Sample pkgutil output:

$ pkgutil --files com.apple.pkg.RosettaUpdateAuto
Library
Library/Apple
Library/Apple/usr
Library/Apple/usr/lib
Library/Apple/usr/lib/libRosettaAot.dylib
Library/Apple/usr/libexec
Library/Apple/usr/libexec/oah
Library/Apple/usr/libexec/oah/debugserver
Library/Apple/usr/libexec/oah/libRosettaRuntime
Library/Apple/usr/libexec/oah/runtime
Library/Apple/usr/libexec/oah/translate_tool
Library/Apple/usr/share
Library/Apple/usr/share/rosetta
Library/Apple/usr/share/rosetta/rosetta

Migrate Homebrew from Intel Macs to Apple Silicon Macs

Dump all your existing Homebrew packages:

brew bundle dump

If you’re using custom shell installed by Homebrew (ie. fish), change it back to bash temporarily:

chsh -s /bin/bash

You may also need to change this in System Preferences – Users & Groups (right click on your avatar and choose Advanced Options…)

Uninstall existing Homebrew (and all its packages):

curl -fsSL -o /tmp/uninstall.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
/bin/bash /tmp/uninstall.sh --path=/usr/local
Continue reading

Fix Invalid Package Name “.DS_Store” for Node.js NPM Global Update on macOS

If you got the following error message when run npm update -g:

$ npm update -g
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name ".DS_Store": name cannot start with a period

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sparanoid/.npm/_logs/2021-04-28T13_59_32_013Z-debug.log

Simply run if you installed your Node.js via Homebrew:

find /usr/local -name '.DS_Store' -type f -print -delete

Or the following for M1:

find /opt/homebrew/lib -name '.DS_Store' -type f -print -delete

macOS Bug: Connecting to another Mac via SMB protocol results in client hanging indefinitely at shutdown or restart

How to force SMB2, which actually doesn’t work for me:

10.14.3 – SMB3 Performance Issues – Force SMB2

Related discussion on Apple Communities

Computers Won’t Shut Down After Connecting To Server

Bug reports on Apple Radar:

How to submit sysdiagnose:

  • Command + Option + Shift+ Control + Period (.)
  • Or in Terminal: sudo sysdiagnose

Note: The sysdiagnose process can take 10 minutes to complete. Once finished, the folder /private/var/tmp/ should appear automatically in the Finder and the sysdiagnose file there will look similar to this:

sysdiagnose_2017.08.17_07-30-12-0700_10169.tar.gz

View active SMB connection status:

smbutil statshares -a