I ran into this same issue today, same exact terminal output that you list above, while trying to install MOS using curl on my new MacBook Pro (BigSur 11.6). This output that you listed:
mkdir: /usr/local/opt/libftdi/lib: Permission denied
curl: (23) Failed writing body (0 != 16096)
Installing libusb-1.0.0.dylib ...
mkdir: /usr/local/opt/libusb/lib: Permission denied
curl: (23) Failed writing body (0 != 16094)
was caused by the directory opt
in the path /usr/local/opt
not being present. The permissions on the directory local
are read&write for the system only so the mkdir
fails and the opt
is not created. Interestingly, by installing brew as @nliviu suggested above, that process creates these directories using sudo
in the script. From the brew install:
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks
or you could
/usr/bin/sudo /bin/mkdir -p /usr/local/opt
Note the mkdir -p is to create the parent directories if needed. Then running the curl script after as you listed, allows the script to complete. I wish I could say that solves the problem, however there is a remaining issue with the library libusb-1.0.0.dylib.
jimwoolaway@Jims-MBP ~ % mos
dyld: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
Referenced from: /usr/local/bin/mos
Reason: Incompatible library version: mos requires version 4.0.0 or later, but libusb-1.0.0.dylib provides version 2.0.0
zsh: abort mos
I have also tried to install MOS using Brew on BigSur which also fails to run for the same issue.
jimwoolaway@Jims-MBP ~ % brew install mos
Warning: cesanta/mos/mos 2.19.1 is already installed and up-to-date.
To reinstall 2.19.1, run:
brew reinstall mos
jimwoolaway@Jims-MBP ~ % mos
dyld: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
Referenced from: /usr/local/bin/mos
Reason: Incompatible library version: mos requires version 4.0.0 or later, but libusb-1.0.0.dylib provides version 2.0.0
zsh: abort mos
I see from brew doctor:
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
libftdi
libusb
running the brew link:
jimwoolaway@Jims-MBP ~ % brew link libftdi
Linking /usr/local/Cellar/libftdi/1.5_2... Error: Directory not empty @ dir_s_rmdir - /usr/local/opt/libftdi
jimwoolaway@Jims-MBP ~ % brew link libusb
Linking /usr/local/Cellar/libusb/1.0.24... Error: Directory not empty @ dir_s_rmdir - /usr/local/opt/libusb
Delete the Libraries folders /usr/local/opt/libusb and /usr/local/opt/libftdi. Then run the link again:
jimwoolaway@Jims-MBP opt % brew link libusb
Linking /usr/local/Cellar/libusb/1.0.24... 6 symlinks created.
jimwoolaway@Jims-MBP opt % brew link libftdi
Linking /usr/local/Cellar/libftdi/1.5_2... 16 symlinks created.
jimwoolaway@Jims-MBP opt % mos
First run of the version 2.19.1, initializing...
Init done.
The MOS can be difficult to install on the Mac but it is worth the effort.