darling
darling copied to clipboard
`xcode-select --install` cannot install to /Library/Developer/DarlingCLT
Expected Result
sudo xcode-select --install installs command line tools to /Library/Developer/DarlingCLT, then any regular user should be able to invoke those tools.
Actual Result
- In
darling shell(unprivileged Linux host user),sudo xcode-select --installfailed and prompted "cannot create symlink". - In
sudo darling shell(Linux host root),xcode-select --installsucceeded, but installed command line tools to/Library/Developer/CommandLineTools, and this directory does not exist in an unprivilegeddarling shell, making those tools unusable.
Steps To Reproduce
- In
darling shell:
Darling [/Volumes/SystemRoot/data/home/zepp]$ sudo xcode-select --install
You are about to download and install Apple Command Line Tools covered by the following license:
https://www.apple.com/legal/sla/docs/xcode.pdf
Do you agree with the terms of the license? (y/n) y
Downloading packages...
Downloading DevSDK_OSX1012.pkg...
Installing...
installer: Installing package com.apple.pkg.DevSDK_OSX1012 version 9.2.0.0.1.1510905681 (261534 KB)
installer: Extracting files
Cannot create symlink /./System/Library/Frameworks/AGL.framework/Headers: Permission denied
Installation failed with exit code 1
- In
sudo darling shell:
Darling [/Volumes/SystemRoot/data/home/zepp]# xcode-select --install
You are about to download and install Apple Command Line Tools covered by the following license:
https://www.apple.com/legal/sla/docs/xcode.pdf
Do you agree with the terms of the license? (y/n) y
Downloading packages...
Downloading DevSDK_OSX1012.pkg...
Installing...
installer: Installing package com.apple.pkg.DevSDK_OSX1012 version 9.2.0.0.1.1510905681 (261534 KB)
installer: Uninstalling previous version 9.2.0.0.1.1510905681
installer: Extracting files
installer: Installation complete
Downloading CLTools_SDK_macOS1013.pkg...
Installing...
installer: Installing package com.apple.pkg.CLTools_SDK_macOSSDK version 9.2.0.0.1.1510905681 (313954 KB)
installer: Uninstalling previous version 9.2.0.0.1.1510905681
Warning: cannot unlink //Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/SDKSettings.plist
Warning: cannot unlink //Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/CoreServices/SystemVersion.plist
# Omitting hundreds of similar warnings...
Installation complete!
Darling [/Volumes/SystemRoot/data/home/zepp]# xcode-select --print-path
/Library/Developer/CommandLineTools/
Darling [/Volumes/SystemRoot/data/home/zepp]# clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
- Seems installed, right? Wait a minute, let's go back into
darling shell:
Darling [/Volumes/SystemRoot/data/home/zepp]$ xcode-select --print-path
/Library/Developer/DarlingCLT/
Darling [/Volumes/SystemRoot/data/home/zepp]$ ls /Library/Developer
DarlingCLT
Darling [/Volumes/SystemRoot/data/home/zepp]$ xcode-select --switch /Library/Developer/CommandLineTools
xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'
System Information What system are you using?
| Software | Version |
|---|---|
| Linux Kernel | 5.4.119 |
| Darling | tested against v0.1.20220704 and f31e04e, both built with -DJSC_UNIFIED_BUILD=ON -DTARGET_i386=OFF |
FYI, I'm running CentOS 8 inside KVM as Linux host, but I don't think that matters.
#1166 seems like the same issue
Just came across the same issue again, and this time I finally figured out the reason.
Inside darling shell, the filesystem you see is synthesized by OverlayFS, which lives in a separate mount namespace. To take a look:
$ ps aux | grep darling
zepulu 3228913 0.0 0.0 142504 30012 pts/76 Sl 17:28 0:01 darlingserver /home/zepp/.darling 259483 100 4 0
$ sudo cat /proc/3228913/mounts | grep darling
overlay /home/zepp/.darling overlay rw,relatime,lowerdir=/opt/darling-v0.1.20230310_update_sources_11_5/libexec/darling,upperdir=/home/zepp/.darling,workdir=/home/zepp/.darling.workdir,index=off 0 0
$ ls /opt/darling-v0.1.20230310_update_sources_11_5/libexec/darling/
bin dev etc Library private proc sbin System tmp usr var Volumes
$ ls ~/.darling
Applications dslocal-backup.xar private Users usr var Volumes
So in this case, darling root filesystem is combined by $PREFIX/libexec/darling and $HOME/.darling. For some unknown reasons, the latter has neither Library nor System sub-directory, so the path xcode-select installs to actually resides in the former one, which I have no permission, thus failed.
When invoked with sudo, things are installed to /root/.darling, so they are invisible to normal users.
Solution
$ sudo chown -R my_user:my_group $PREFIX/libexec/darling/Library/Developer
$ darling shell # install whatever you want
$ sudo chown -R root:root $PREFIX/libexec/darling/Library/Developer # restore permissions