ohueter/autokbisw

Build fails on M1 Macbook Pro

Rithari opened this issue · 11 comments

Hi there,

I've cloned the repo and tried to build it using swift build --configuration release, however, after it complained about not finding a prebuilt standard library for arm64, it errored out with package.swift:4:8: error: no such module 'PackageDescription' import PackageDescription is a recurring error I have seen with other previously downloaded XCode projects. This might be entirely on me, however, I do not know enough about Swift development to be able to come up with a solution to the issue.

Hi @Rithari, autokbisw should compile without issues on an M1 Mac. Are the XCode Command Line Tools installed on your system? See https://docs.brew.sh/Installation#macos-requirements, you can install them by running xcode-select --install in a Terminal. Does this help?

Hi, MacBook Pro M1 and same issue over here

> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
> brew install ohueter/tap/autokbisw
==> Downloading https://github.com/ohueter/autokbisw/archive/refs/tags/1.4.3.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/e7a80ab5fffc75fac79fa93cc7e56258b5446b2474eefb1aaa86eb5aff5c1c2b--autokbisw-1.4.3.tar.gz
==> Installing autokbisw from ohueter/tap
==> swift build -c release --disable-sandbox
Last 15 lines from /Users/user/Library/Logs/Homebrew/autokbisw/01.swift:
swift
build
-c
release
--disable-sandbox

warning: /Users/user/Library/org.swift.swiftpm/configuration is not accessible or not writable, disabling user-level configuration features.
warning: /Users/user/Library/org.swift.swiftpm/security is not accessible or not writable, disabling user-level security features.
warning: /Users/user/Library/Caches/org.swift.swiftpm is not accessible or not writable, disabling user-level cache features.
warning: 'autokbisw-1.4.3': failed loading cached manifest for 'autokbisw-1.4.3': Error Domain=NSCocoaErrorDomain Code=4 "The file “manifests” doesn’t exist." UserInfo={NSFilePath=/Users/user/Library/Caches/org.swift.swiftpm/manifests, NSUnderlyingError=0x600003469710 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
warning: 'autokbisw-1.4.3': failed closing cache: Error Domain=NSCocoaErrorDomain Code=4 "The file “manifests” doesn’t exist." UserInfo={NSFilePath=/Users/user/Library/Caches/org.swift.swiftpm/manifests, NSUnderlyingError=0x600003464810 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
error: 'autokbisw-1.4.3': Invalid manifest
/private/tmp/autokbisw-20221007-20542-1cuxhp4/autokbisw-1.4.3/Package.swift:4:8: error: no such module 'PackageDescription'
import PackageDescription
       ^

Do not report this issue to Homebrew/brew or Homebrew/core!
```

Hi @ohueter,
Same problem here, with Xcode and Command Line Tools installed on M1 machine.
I also tried building it from source, but same issue.
Here's the output:

autokbisw OSKAR$ swift build --configuration release
error: 'autokbisw': Invalid manifest
/Users/OSKAR/Config/autokbisw/Package.swift:4:8: error: no such module 'PackageDescription'
import PackageDescription
       ^

Hi @ohueter and @Rithari,

So I found a workaround: the issue shows only with the latest Command Line Tools, to build correctly you need an older version of them. I tried downloading the 13.4 version and it worked.
@Rithari for the Command Line Tool you can download it manually and install through this link. Be aware that you need an Apple Developer account.

@ohueter I think that some import rules changed with the latest version on the package import side, sorry but I'm not on Swift development at all, so can't help you too much. I figured out that something was wrong with them because of the version indicated in Package.swift

Hi all,

I can confirm I do have the latest command line tools installed, however will not be installing the older version of them - I'll wait for an update that fixes the current issue, as-is. Thank you though!

Thank you all for reporting and investigating! I‘ll try to look into this next week. Any further help is greatly appreciated, as I’m not that familiar with Swift as well 🤣

I'm sorry but I can't reproduce this. I was suspecting some older versions on my machine, but after updating everything, autokbisw still compiles fine. I'm running:

  • macOS 12.6 Monterey on an M1 Macbook
  • XCode and Command Line Tools version 14.0.1
    $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    package-id: com.apple.pkg.CLTools_Executables
    version: 14.0.0.0.1.1661618636
    
  • Compiling a freshly cloned repo (even with disabled dependency cache) works fine:
     $ swift build -c release --disable-sandbox --disable-dependency-cache
    Fetching https://github.com/apple/swift-argument-parser
    Fetched https://github.com/apple/swift-argument-parser (3.22s)
    Computing version for https://github.com/apple/swift-argument-parser
    Computed https://github.com/apple/swift-argument-parser at 1.0.2 (0.02s)
    Creating working copy for https://github.com/apple/swift-argument-parser
    Working copy of https://github.com/apple/swift-argument-parser resolved at 1.0.2
    Building for production...
    [4/4] Linking autokbisw
    Build complete! (12.21s)
    
  • Building with Homebrew without any caches works as well:
    $ brew cleanup -s
    $ rm -rf $(brew --cache)
    $ brew install ohueter/tap/autokbisw
    ==> Downloading https://github.com/ohueter/autokbisw/archive/refs/tags/1.4.3.tar.gz
    ==> Downloading from https://codeload.github.com/ohueter/autokbisw/tar.gz/refs/tags/1.4.3
    #=#=#                                                                         
    ==> Installing autokbisw from ohueter/tap
    ==> swift build -c release --disable-sandbox
    ==> Caveats
    To restart ohueter/tap/autokbisw after an upgrade:
      brew services restart ohueter/tap/autokbisw
    Or, if you don't want/need a background service you can just run:
      autokbisw
    ==> Summary
    🍺  /opt/homebrew/Cellar/autokbisw/1.4.3: 6 files, 1.6MB, built in 19 seconds
    ==> Running `brew cleanup autokbisw`...
    Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
    Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
    

Could you run

xcode-select --print-path

and post the output? It should be /Applications/Xcode.app/Contents/Developer. If it's not, could see if running sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer fixes the compilation?

Hey @ohueter,

I can confirm that my path was different because I probably installed it in my Developer folder some time ago. Re-linking the path to the one expected does indeed fix the issue and the repository compiles without any issues.

Thank you for looking into it, the issue can be closed as resolved unless there is anything further you'd like to add.

My path is the default one for CLI tools at the moment, /Library/Developer/CommandLineTools.
Is this a caveat needed for this to be installed on Mac M1? Asking this, because it would mean requiring the full XCode.

As far as I can say, a full Xcode installation is required, yes. This is not specific to M1.

This seems to be mostly resolved, right? I'll close this for now. Maybe Homebrew will provide bottles for autokbisw some day :-)