techouse / alfred-tailwindcss-docs

Search the Tailwind CSS documentation using Alfred
MIT License
56 stars 3 forks source link

Apple M1 support #2

Closed tizot closed 1 year ago

tizot commented 1 year ago

Hi,

The workflow unfortunately does not work on Apple MacBook M1. When the script is executed, I see the message "Bad CPU type in executable". I guess this is due to the fact that it is compiled to a binary with Dart now.

techouse commented 1 year ago

Correct that is a known limitation of the binary compilation process.

The exe subcommand has some known limitations:

No cross-compilation support (issue 28617) The compiler can create machine code only for the operating system on which you’re compiling. To create executables for > macOS, Windows, and Linux, you need to run the compiler three times. You can also use a continuous integration (CI) > provider that supports all three operating systems.

Unfortunately, I do not own an Apple M1 yet, therefore the compiled binary is x86_64.

➜  tailwindcss-docs-alfred-workflow git:(master) file build/dist/docs 
build/dist/docs: Mach-O 64-bit executable x86_64

You have 2 options to run this on your Apple M1:

Option A: Use Rosetta

softwareupdate --install-rosetta

Option B: Compile the workflow from scratch on your own machine.

This one is a bit more involved, but all you have to do is.

# install the Dart SDK
brew tap dart-lang/dart
brew install dart

# clone the repo
git clone https://github.com/techouse/alfred-tailwindcss-docs
cd alfred-tailwindcss-docs

# edit the env
cp .env.example .env
vim .env

# generate all the environment-dependent files
make code_gen

# compile the app
make compile
techouse commented 1 year ago

I'll add a wrapper script to detect the architecture and run it as required.

techouse commented 1 year ago

Right, v2.1.10 is now executed as

arch -x86_64 ./docs -q "{query}"

That should force the OS to run it as such.