Description
I am using the swiftly toolchain manager, which installs only open source macOS toolchains and they are all installed in the current user's home directory ~/Library/Developer/Toolchains
, not in /Library/Developer/Toolchains
. I do not have any toolchains installed in the system.
When trying to build with Swift Build in this environment with the current latest main snapshot (main-snapshot-2025-03-25) that has the swiftbuild build system I get the following error initially:
% swift build --build-system=swiftbuild
error: failed to load toolchains in /Library/Developer/CommandLineTools/Toolchains: Error Domain=NSCocoaErrorDomain Code=260 "The folder “Toolchains” doesn’t exist." UserInfo={NSUserStringVariant=(
Folder
), NSFilePath=/Library/Developer/CommandLineTools/Toolchains, NSURL=file:///Library/Developer/CommandLineTools/Toolchains, NSUnderlyingError=0x600001f2cf90 {Error Domain=NSOSStatusErrorDomain Code=-43 "fnfErr: File not found"}}
error: missing required default toolchain
error: Could not initialize build system
After manually creating an empty directory in there the error becomes the following:
% swift build --build-system=swiftbuild
error: missing required default toolchain
error: Could not initialize build system
It seems that Swift Build requires that there is at least one default toolchain installed on the system.
Expected result:
Because it is bundled with the Swift toolchain it should be able to find its own toolchain, even if it is in the user's home directory.