XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.68k stars 126 forks source link

Error installing via Homebrew on M1 #148

Closed Saelyria closed 1 year ago

Saelyria commented 3 years ago

Hello!

I was trying to install on an M1 Mac mini via Homebrew, but I'm running into the following error:

make
install
prefix=/opt/homebrew/Cellar/xcodes/0.17.0

error: terminated(72): HOMEBREW_ANALYTICS_USER_UUID=5F2AFA1B-A39F-4154-9C0B-916EAE829EF4 MAKEOVERRIDES=${-*-command-variables-*-} HOMEBREW_GIT_CONFIG_FILE=/opt/homebrew/Homebrew/.git/config TERM=xterm-256color HOMEBREW_LIBRARY=/opt/homebrew/Homebrew/Library HOMEBREW_BREW_DEFAULT_GIT_REMOTE=https://github.com/Homebrew/brew CARGO_HOME=/Users/Administrator/Library/Caches/Homebrew/cargo_cache ACLOCAL_PATH=/opt/homebrew/share/aclocal TMPDIR=/private/tmp CC=clang GOCACHE=/Users/Administrator/Library/Caches/Homebrew/go_cache TMP=/private/tmp HOMEBREW_CELLAR=/opt/homebrew/Cellar MFLAGS=- --jobserver-fds=3,4 -j HOMEBREW_DEPENDENCIES= MAKELEVEL=1 HOMEBREW_USER_AGENT_CURL=Homebrew/3.1.5 (Macintosh; arm64 Mac OS X 11.2.3) curl/7.64.1 HOMEBREW_CACHE=/Users/Administrator/Library/Caches/Homebrew HOMEBREW_ARCHFLAGS= HOMEBREW_CC_LOG_PATH=/Users/Administrator/Library/Logs/Homebrew/xcodes/01.make HOME=/private/tmp/xcodes-20210503-31493-19bsi4e/.brew_home HOMEBREW_NO_BOOTSNAP=1 HOMEBREW_REQUIRED_RUBY_VERSION=2.6.3 OBJC=clang HOMEBREW_PROCESSOR=arm64 HOMEBREW_BOTTLE_DEFAULT_DOMAIN=https://ghcr.io/v2/homebrew/core HOMEBREW_SYSTEM=Macintosh CXX=clang++ HOMEBREW_OPTFLAGS= SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk MAKEFLAGS= --jobserver-fds=3,4 -j -- prefix=/opt/homebrew/Cellar/xcodes/0.17.0 HOMEBREW_COMMAND_DEPTH=2 HOMEBREW_BREW_GIT_REMOTE=https://github.com/Homebrew/brew HOMEBREW_LIBRARY_PATHS=/opt/homebrew/lib:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries HOMEBREW_MACOS_VERSION=11.2.3 HOMEBREW_REPOSITORY=/opt/homebrew/Homebrew HOMEBREW_OS_VERSION=macOS 11.2 HOMEBREW_RUBY_WARNINGS=-W1 prefix=/opt/homebrew/Cellar/xcodes/0.17.0 __CF_USER_TEXT_ENCODING=0x1F6:0x0:0x52 HOMEBREW_FORMULA_PREFIX=/opt/homebrew/Cellar/xcodes/0.17.0 HOMEBREW_AUTO_UPDATE_CHECKED=1 HOMEBREW_CORE_DEFAULT_GIT_REMOTE=https://github.com/Homebrew/homebrew-core HOMEBREW_CORE_GIT_REMOTE=https://github.com/Homebrew/homebrew-core HOMEBREW_DEFAULT_LOGS=/Users/Administrator/Library/Logs/Homebrew HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH=1 HOMEBREW_LOGS=/Users/Administrator/Library/Logs/Homebrew HOMEBREW_ERROR_PIPE=/private/tmp/homebrew20210503-30518-1jfis6f/socket HOMEBREW_PRODUCT=Homebrew HOMEBREW_PREFER_CLT_PROXIES=1 HOMEBREW_ANALYTICS_ID=UA-76679469-1 HOMEBREW_CURL=curl CMAKE_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers HOMEBREW_ISYSTEM_PATHS=/opt/homebrew/include:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers HOMEBREW_SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk LOGNAME=Administrator HOMEBREW_PREFIX=/opt/homebrew HOMEBREW_CC=clang PWD=/private/tmp/xcodes-20210503-31493-19bsi4e TEMP=/private/tmp HOMEBREW_MINIMUM_GIT_VERSION=2.14.3 CMAKE_PREFIX_PATH=/opt/homebrew HOMEBREW_GIT=git SOURCE_DATE_EPOCH=1614371456 HOMEBREW_CXX=clang++ HOMEBREW_ENV=super SHLVL=1 OBJCXX=clang++ USER=Administrator HOMEBREW_MACOS_VERSION_NUMERIC=110203 HOMEBREW_RUBY_PATH=/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby CURL_HOME=/Users/Administrator SHELL=/bin/zsh HOMEBREW_OPTIMIZATION_LEVEL=Os HOMEBREW_USER_AGENT=Homebrew/3.1.5 (Macintosh; arm64 Mac OS X 11.2.3) PATH=/opt/homebrew/Homebrew/Library/Homebrew/shims/mac/super:/usr/bin:/bin:/usr/sbin:/sbin GOPATH=/Users/Administrator/Library/Caches/Homebrew/go_mod_cache HOMEBREW_DEVELOPER_DIR=/Library/Developer/CommandLineTools LC_ALL=en_US.UTF-8 PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/opt/homebrew/Homebrew/Library/Homebrew/os/mac/pkgconfig/11 HOMEBREW_VERSION=3.1.5 _=/usr/bin/swift HOMEBREW_DEFAULT_CACHE=/Users/Administrator/Library/Caches/Homebrew HOMEBREW_BREW_FILE=/opt/homebrew/bin/brew HOMEBREW_DEFAULT_TEMP=/private/tmp HOMEBREW_OPT=/opt/homebrew/opt _JAVA_OPTIONS=-Duser.home=/Users/Administrator/Library/Caches/Homebrew/java_cache HOMEBREW_TEMP=/private/tmp CMAKE_LIBRARY_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries HOMEBREW_CCCFG=Oa /usr/bin/xcrun --sdk macosx --find xctest output:
    xcrun: error: unable to find utility "xctest", not a developer tool or in PATH

make: *** [xcodes] Error 1

It's a pretty close to fresh install of macOS, so Xcode is not already installed (which seems to be the root cause of the unable to find utility "xctest" error based on some cursory googling).

Let me know if there's any other info I can provide!

MattKiazyk commented 3 years ago

Hi @Saelyria

That is the error when you run?:

brew install robotsandpencils/made/xcodes

In your example above you have make install which is how you would build from source. When you do that you need an Xcode installed on your machine.

Let me know if brew install above works?

Thanks

mmaietta commented 3 years ago

Hi @MattKiazyk! I'm also running into this issue. Here's the output of brew install robotsandpencils/made/xcodes > pbcopy

I think it's running make because it needs to be recompiled for arm64? I can also confirm that I have Xcode installed (12.4).

==> make install prefix=/opt/homebrew/Cellar/xcodes/0.17.0
Last 15 lines from /Users/michaelmaietta/Library/Logs/Homebrew/xcodes/01.make:
2021-05-04 15:20:15 -0700

make
install
prefix=/opt/homebrew/Cellar/xcodes/0.17.0

error: terminated(72): /usr/bin/xcrun --sdk macosx --find xctest output:
    xcrun: error: unable to find utility "xctest", not a developer tool or in PATH

make: *** [xcodes] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!
Saelyria commented 3 years ago

Yeah, my error output is from running brew install when Xcode is not installed. When it is already installed (I downloaded 12.5 manually to check), I get:

==> Installing xcodes from robotsandpencils/made
==> Cloning https://github.com/RobotsAndPencils/xcodes.git
Updating /Users/Administrator/Library/Caches/Homebrew/xcodes--git
==> Checking out tag 0.17.0
HEAD is now at c9c1784 Bump version to 0.17.0
HEAD is now at c9c1784 Bump version to 0.17.0
==> make install prefix=/opt/homebrew/Cellar/xcodes/0.17.0
==> xcodes cask is installed, skipping link.
🍺  /opt/homebrew/Cellar/xcodes/0.17.0: 5 files, 7.7MB, built in 1 minute 25 seconds

so it does succeed, but it is still running make.

@mmaietta your assumption sounds reasonable - also, to get it working with Homebrew with Xcode installed, I made sure xcode-select -p was pointing to the Xcode install's CLT (as per this SO answer)

mmaietta commented 3 years ago

I can confirm that xcode-select -s <xcode developer path> resolved the issue. Thanks @Saelyria!

supersonicbyte commented 3 years ago

Hey, I get the same error

make
install
prefix=/opt/homebrew/Cellar/xcodes/0.17.0

error: terminated(72): /usr/bin/xcrun --sdk macosx --find xctest output:
    xcrun: error: unable to find utility "xctest", not a developer tool or in PATH

make: *** [xcodes] Error 1

when trying to run brew install robotsandpencils/made/xcodes without having a prior installation on my macbook pro M1.

MattKiazyk commented 3 years ago

@tylerwetrust Curious if you have Rosetta installed on that M1 yet?

Saelyria commented 3 years ago

Good point - just double-checked by installing via Rosetta and looks like it doesn't run make, so is a good workaround for the time being if installing Xcode first is prohibitive.

More specifically, I:

and I get the following output:

==> Tapping robotsandpencils/made
Cloning into '/usr/local/Homebrew/Library/Taps/robotsandpencils/homebrew-made'...
remote: Enumerating objects: 83, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 83 (delta 8), reused 32 (delta 7), pack-reused 47
Receiving objects: 100% (83/83), 42.72 KiB | 540.00 KiB/s, done.
Resolving deltas: 100% (18/18), done.
Tapped 1 formula (30 files, 95.4KB).
==> Installing xcodes from robotsandpencils/made
==> Downloading https://github.com/RobotsAndPencils/xcodes/releases/download/0.17.0/xcodes-0.17.0.mojave.bottle.tar.gz
==> Downloading from https://github-releases.githubusercontent.com/171964196/753be900-7841-11eb-9635-36e1bcf2c174?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX
######################################################################## 100.0%
==> Pouring xcodes-0.17.0.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/xcodes/0.17.0: 2 files, 8MB

would still be nice to have an official M1 release :) @MattKiazyk if it's just an issue of just access to M1 hardware, if you can point me to instructions on what all needs to be done, I can do that work on the Mini I have here and open a PR.

supersonicbyte commented 3 years ago

@MattKiazyk I do not have Rosetta installed. @Saelyria thanks for the workaround, but I'm probably gonna wait for an official M1 release.

mmaietta commented 3 years ago

https://github.com/RobotsAndPencils/xcodes/blob/main/Makefile#L21-L25 It could be an easy change to add arm64 support? Didn't test this, just did a quick Google search

Ref: https://forums.swift.org/t/compile-packages-for-arm64-only-how/42547/2

swift build --arch arm64 and xcodebuild ... -destination "platform=macos,arch=arm64" to build on Apple Silicon

It seems it's not possible to build for both archs at the same time, i.e. --arch arm64 --arch x86_64. Instead lipo must be used to stitch the two artifacts together. Ref: https://developer.apple.com/forums/thread/672758

If it helps, here's also a sample script that uses xcodebuild with lipo: https://gist.github.com/madhikarma/09e553c508f870639570

thepoppingone commented 2 years ago

with the new Macbooks coming all with M1s, might want to relook into how we can install xcodes without installing Xcode first. If possible to share the difficulties in making it work for arm64 please do share it. This tool has been extremely helpful for me to automate intel mac machines and we are planning to integrate this into M1 machines as well.

adamjcampbell commented 2 years ago

I'm also seeing this one. The command line tools don't come with xctest on a fresh install on an M1.

adam@MacBook-Pro ~ % brew install robotsandpencils/made/xcodes                       
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 4 formulae.

==> Cloning https://github.com/RobotsAndPencils/xcodes.git
Updating /Users/adam/Library/Caches/Homebrew/xcodes--git
==> Checking out tag 0.17.0
HEAD is now at c9c1784 Bump version to 0.17.0
HEAD is now at c9c1784 Bump version to 0.17.0
==> Installing xcodes from robotsandpencils/made
==> make install prefix=/opt/homebrew/Cellar/xcodes/0.17.0
Last 15 lines from /Users/adam/Library/Logs/Homebrew/xcodes/01.make:
2021-12-08 06:21:15 +0000

make
install
prefix=/opt/homebrew/Cellar/xcodes/0.17.0

error: terminated(72): /usr/bin/xcrun --sdk macosx --find xctest output:
    xcrun: error: unable to find utility "xctest", not a developer tool or in PATH

make: *** [xcodes] Error 1

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/robotsandpencils/homebrew-made/issues

Checking for xcrun and xctest:

adam@MacBook-Pro ~ % which xcrun
/usr/bin/xcrun
adam@MacBook-Pro ~ % which xctest 
xctest not found
muescha commented 2 years ago

i have the same issue on M1

julianxhokaxhiu commented 2 years ago

Has any progress made so far?

DylanBettermannDD commented 2 years ago

https://github.com/apple/swift-package-manager/pull/4146 might fix it. I can test when this change is shipped.

milch commented 2 years ago

I can confirm that this is still an issue. Trying to run brew with --force-bottle gives this error:

Error: --force-bottle passed but robotsandpencils/made/xcodes has no bottle!

So it seems that brew is not happy with the formula. It's not clear to me from the documentation, but the bottles don't seem to support universal binaries. You can edit the formula to include a separate entry for an arm64_mojave bottle, but then brew tries to download the bottle from this location, which doesn't exist:

==> Downloading https://github.com/RobotsAndPencils/xcodes/releases/download/0.20.0/xcodes-0.2
curl: (22) The requested URL returned error: 404

Error: xcodes: Failed to download resource "xcodes"
Download failed: https://github.com/RobotsAndPencils/xcodes/releases/download/0.20.0/xcodes-0.20.0.arm64_mojave.bottle.tar.gz

So to summarize, to make this work:

  1. Add an entry for an arm64_mojave bottle
  2. Add an artifact to the GitHub release with the xcodes-$VERSION.arm64_mojave.bottle.tar.gz name
MattKiazyk commented 2 years ago

@milch do you have an example of what you changed the formula to. I can easily switch to zip up multiple architecutres if that fixes it.

milch commented 2 years ago

Based on my reading of the bottle docs I updated the bottles section in the formula to look like this:

  bottle do
    root_url 'https://github.com/RobotsAndPencils/xcodes/releases/download/0.20.0'
    sha256 cellar: :any_skip_relocation, mojave: "acd0717e5083634c472d17d7b041265f34b197164ecfcf513b812d77ff978c6d"
+   sha256 cellar: :any_skip_relocation, arm64_mojave: "acd0717e5083634c472d17d7b041265f34b197164ecfcf513b812d77ff978c6d"
  end
marcusziade commented 2 years ago

Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

After this xcodes CLI was installed for me.

MattKiazyk commented 1 year ago

I've added this for 1.0 release today. Seems to grab the arm64 on my m1 machine with no issues:

==> Upgrading 1 outdated package:
robotsandpencils/made/xcodes 0.20.0 -> 1.0.0
==> Downloading https://github.com/RobotsAndPencils/xcodes/releases/download/1.0.0/xcodes-1.0.0.arm64_mojave.bottle.tar.gz
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/171964196/d7172cf4-484d-4894-a
######################################################################## 100.0%
==> Upgrading robotsandpencils/made/xcodes
  0.20.0 -> 1.0.0 

==> Pouring xcodes-1.0.0.arm64_mojave.bottle.tar.gz
🍺  /opt/homebrew/Cellar/xcodes/1.0.0: 2 files, 12MB
milch commented 1 year ago

Can confirm that this works:

$ brew install robotsandpencils/made/xcodes
xcodes 0.20.0 is already installed but outdated (so it will be upgraded).
==> Downloading https://github.com/RobotsAndPencils/xcodes/releases/download/1.0.0/xcodes-1.0.
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e6
######################################################################## 100.0%
==> Upgrading robotsandpencils/made/xcodes
  0.20.0 -> 1.0.0

==> Pouring xcodes-1.0.0.arm64_mojave.bottle.tar.gz
🍺  /opt/homebrew/Cellar/xcodes/1.0.0: 2 files, 12MB

Thank you!

julianxhokaxhiu commented 1 year ago

Can confirm as well it woks, thank you!