cosmopolitan icon indicating copy to clipboard operation
cosmopolitan copied to clipboard

Redbean MacOS incompatibility

Open tkothadev opened this issue 1 year ago • 4 comments

Hello, I'm excited about the project, and wish it all the best.

I tried downloading redbean.com directly to try out the executable format, but it doesn't seem to work. This is what I've tried:

curl https://redbean.dev/redbean-demo-2.0.19.com >redbean.com
chmod +x redbean.com
./redbean.com

I get the following error message: zsh: exec format error: ./redbean.com I'm running this from a MacBook Pro with Mac OS Monterey (12.6.6). I tested this from both iterm2 and the native terminal (both are configured with zshell, in case that is the likely cause).

Please let me know if there's anything I'm missing on my end to make this work.

tkothadev avatar Jul 18 '23 00:07 tkothadev

I'm also new to redbean, but I was able to make it work by doing two things (after, that is, chmod +x):

  • First, I renamed the file to get rid of the .com extension.
  • Second, I right-clicked the file in Finder and selected "Open".

The second step opened a prompt that allowed me to say, yes, it was OK to run the executable. After that I was able to run it in Terminal.

There might be better ways to handle these things, but at this point I just wanted a quick solution so that I could try it out.

michaellenaghan avatar Jul 20 '23 18:07 michaellenaghan

Just following up to say that I tried downloading other variants of redbean to my Mac, and I was able to run them without doing anything other than chmod +x.

I think the difference is that I downloaded the first executables using Safari, and the rest using wget. I think Safari marked the downloads as untrusted, etc.

One suggestion: use -o with curl, rather than redirecting the output. I just tried that, and it worked too.

michaellenaghan avatar Jul 20 '23 23:07 michaellenaghan

Something else: if you're on a M1/2 Mac, then as far as I understand it the steps are different (and, currently, rather involved).

The steps are described in the README, but basically they boil down to this:

  1. Compile one particular C file directly on the ARM machine
  2. Cross-compile for ARM (aarch64) on an x86 machine
  3. Copy the cross compiled executable to the ARM machine
  4. Use the executable from (1) to launch the executable from (2)

Using that approach I was able to run redbean.com and more on an M1 Mac.

michaellenaghan avatar Jul 24 '23 17:07 michaellenaghan

If you're on an M1/2 Mac, see #847. I was able to get redbean-demo-2.2.com running under Rosetta.

michaellenaghan avatar Jul 24 '23 20:07 michaellenaghan