Live data from Hacker News

Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

notion.so

111–120 of 148 posts

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#111

I wonder if Nix on macOS could become a better homebrew-killer by supporting Apple Silicon first. We already do aarch64-linux natively and some iOS cross compilation, so that should give us a head start.

I was using gentoo-prefix for the longest time on MacOS. I never got why homebrew got so popular given how terrible it is. But it was more accessible to people unfortunately. I spent some time trying to become a Gentoo developer for a while and then just gave up because there was no response. I used to updated the clang patches to make newer clang versions compile things on osx before most of those things made it ups…

I wonder if the impressive compile times coming out of M1 will make pre-built binaries less important?

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#112

Earlier quoted context omitted.

Homebrew maintainer here. We don’t officially support Big Sur yet, but installing it via Rosetta will cause it to fetch x86 bottles instead of ARM ones. At least, that’s the plan.

Off-topic: Thanks for working on Homebrew btw! It just occurred to me that I've never donated despite using it so much but now I have. Link for others: https://github.com/homebrew/brew#donations

Thank you for the kind words, and for the donation!

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#114
post #86

Earlier quoted context omitted.

Is this actually GDPR compliant as it is?

If it doesn't ask for consent and stores PII then no, it's not.

Homebrew does not and has never stored any PII. You can read exactly what we store here[1].

[1]: https://docs.brew.sh/Analytics

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#115
post #104

Earlier quoted context omitted.

Stickiness of architecture is a change from how Rosetta worked in the PowerPC to Intel transition: in macOS Big Sur child processes will prefer the arch of the parent process if one is available to maximize compatibility. So for example launching x86_64 sh will cause a python invocation from that shell to also be x86_64. The "arch" utility is your escape hatch to switch the preferred arch for the spawned process and…

Would be easy to make iTerm2 launch arch -x86_64

I haven't tried this (don't have an M1 to hand!) but:

iterm2 -> Preferences -> Profiles -> General

Change the "Login Shell" drop down to "Command" and then enter `arch -x86_64 /usr/local/bin/zsh` or whatever your shell is.

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#116
post #110
post #106

Earlier quoted context omitted.

It's in the base OS actually.

Nope. Python2 is inbox, but Python3 redirects to the Xcode/developer tools copy. % sw_vers ProductName: macOS ProductVersion: 11.1 BuildVersion: 20C5048k % ls /Library/Python/ 2.7 % ls /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/ Headers Python3 Resources Versions % ls /System/Library/Frameworks/Python.framework/ Python Resources Versions

Ok. Well, I don't have the Xcode command line tools installed. This is what I see:

  % ls -l /usr/bin/python*
  lrwxr-xr-x  1 root  wheel      75 Jan  1  2020 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  lrwxr-xr-x  1 root  wheel      82 Jan  1  2020 /usr/bin/python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
  lrwxr-xr-x  1 root  wheel      75 Jan  1  2020 /usr/bin/python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  lrwxr-xr-x  1 root  wheel      75 Jan  1  2020 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  lrwxr-xr-x  1 root  wheel      82 Jan  1  2020 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
  -rwxr-xr-x  1 root  wheel  137536 Jan  1  2020 /usr/bin/python3
  lrwxr-xr-x  1 root  wheel      76 Jan  1  2020 /usr/bin/pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
  lrwxr-xr-x  1 root  wheel      76 Jan  1  2020 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

  % ls -l /usr/bin/pip*
  -rwxr-xr-x  1 root  wheel  137536 Jan  1  2020 /usr/bin/pip3
I had assumed that /usr/bin/python3 was part of the system, since it is not a symlink. But then when I do this, I see it is indeed hitting Xcode:

   % /usr/bin/python3
  objc[12852]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x20ab7e7a0) and ?? (0x1143782b8). One of the two will be used. Which one is undefined.
  objc[12852]: Class AMSupportURLSession is implemented in both ?? (0x20ab7e7f0) and ?? (0x114378308). One of the two will be used. Which one is undefined.
  Python 3.8.2 (default, Oct  2 2020, 10:45:41)
  [Clang 12.0.0 (clang-1200.0.32.27)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import os
  >>> print(os.environ['PYTHONPATH'])
  Traceback (most recent call last):
    File "", line 1, in 
    File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/os.py", line 675, in __getitem__
      raise KeyError(key) from None
  KeyError: 'PYTHONPATH'
So Xcode is definitely involved.

EDIT: So I uninstalled Xcode. /usr/bin/python3 is there, but it is clearly a stub file of some sort. If you run it without Xcode or Xcode command line tools installed, you get a popup to install the command line tools. So python3 is not part of the system, but the stubs for it are. Thanks for the patience.

Even more interesting, if you have Xcode, but not the command line tools, the stub launches Python3.8 from the Xcode installation. Once you install the command line tools, it then switches to launching that version. Presumably this is all because of the read-only system volume.

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#117
post #115
post #104

Earlier quoted context omitted.

Would be easy to make iTerm2 launch arch -x86_64

I haven't tried this (don't have an M1 to hand!) but: iterm2 -> Preferences -> Profiles -> General Change the "Login Shell" drop down to "Command" and then enter `arch -x86_64 /usr/local/bin/zsh` or whatever your shell is.

Would `arch -x86_64 $SHELL` work?

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#118
post #15

Or just use iTerm, which is Intel-only so far.

iTerm2 3.4 (now 3.4.1) shipped a day or two ago; it's a universal binary.

I made the mistake of trying to install the nightly and somehow got iTerm instead of iTerm2. My bad. Thanks for the heads up.

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#119
post #66

I wonder if Nix on macOS could become a better homebrew-killer by supporting Apple Silicon first. We already do aarch64-linux natively and some iOS cross compilation, so that should give us a head start.

Related issue[0]. I moved over from Homebrew to Nix around 5 months ago, haven't since needed to use Homebrew except for casks. [0] "Support for Apple Silicon (aarch64-darwin)" https://github.com/NixOS/nixpkgs/issues/95903

It can replace casks too, as mac apps can also be packaged in Nix.

Re: Run x86 Apps (including homebrew) in the Terminal on Apple Silicon

#120
post #46

I wonder if Nix on macOS could become a better homebrew-killer by supporting Apple Silicon first. We already do aarch64-linux natively and some iOS cross compilation, so that should give us a head start.

macports is a better homebrew-killer IMHO. Follows MacOS guidelines and frameworks, integrates with the MacOS way in terms of launch agents etc.

Nix also runs and integrates with macOS too. Does macports do something that Nix doesn’t?
Post reply on HN