JamieMason / ImageOptim-CLI

Make optimisation of images part of your automated build process
https://foldleft.io/image-tools
MIT License
3.46k stars 126 forks source link

Unable to install on M1 / Apple Silicon #191

Closed inspiredearth closed 2 years ago

inspiredearth commented 3 years ago

Steps To Reproduce The Error

Try to install the package on an M1 Mac.

Expected Behaviour

Install as per normal.

Actual Behaviour

It runs into issues withnode@10, as shown in this output:

Warning: node@10 has been deprecated because it is not supported upstream!
Error: node@10: no bottle available!
You can try to install from source with:
  brew install --build-from-source node@10
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.

Building node@10 from source does not work.

It results in this output:

==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/manifests/69.1
Already downloaded: /Users/jonathan/Library/Caches/Homebrew/downloads/319330d53dab436f7e6bbe478539f29d41abb6be79788b06615f28006a82b30c--icu4c-69.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/blobs/sha256:25a1ec460d422ba5abff15dc5cb60ad36003ad021585fa7be278d1dca6fcd2c4
Already downloaded: /Users/jonathan/Library/Caches/Homebrew/downloads/ccf6b67f22944e4ef3d02f6108f71d827eb5193bfeb2a23b10a3471f43e79874--icu4c--69.1.arm64_big_sur.bottle.tar.gz
==> Downloading https://nodejs.org/dist/v10.24.1/node-v10.24.1.tar.xz
######################################################################## 100.0%
Warning: node@10 has been deprecated because it is not supported upstream!
==> Installing dependencies for node@10: icu4c
==> Installing node@10 dependency: icu4c
==> Pouring icu4c--69.1.arm64_big_sur.bottle.tar.gz
🍺  /opt/homebrew/Cellar/icu4c/69.1: 259 files, 73.3MB
==> Installing node@10
==> ./configure --prefix=/opt/homebrew/Cellar/node@10/10.24.1_1 --with-intl=system-icu
Last 15 lines from /Users/jonathan/Library/Logs/Homebrew/node@10/01.configure:
                 'v8_no_strict_aliasing': 1,
                 'v8_optimized_debug': 0,
                 'v8_promise_internal_field_count': 1,
                 'v8_random_seed': 0,
                 'v8_trace_maps': 0,
                 'v8_typed_array_max_size_in_heap': 0,
                 'v8_use_snapshot': 'true',
                 'want_separate_host_toolset': 0,
                 'xcode_version': '12.0'}}
creating config.gypi
creating config.status
creating config.mk
running:
    python tools/gyp_node.py --no-parallel -f make-mac
Error running GYP

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

Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels.

Version Numbers or N/A

Help Needed

Is there any way around this? Is there a way to run ImageOptim-CLI on an M1 Mac?

What are the options?

JamieMason commented 3 years ago

@inspiredearth @matthewferry @jwryan9 @shuguenot @sebastienbarre I have updated the version of node.js which imageoptim is built with to 12.18.2, hopefully this will solve this issue.

This is in imageoptim-cli@3.0.7 which has just been released, it might take some time before it appears on homebrew (I don't control that).

sebastienbarre commented 3 years ago

Thanks.

I just cloned the repo to test it out manually.

OberstKrueger commented 2 years ago

Tangential, but based on this pull request, it looks like imageoptim not being updated is blocking the homebrew formula from being updated.

joelbowen commented 2 years ago

What needs to be done to update the homebrew formula? Still seeing 3.0.2 and unable to install on Apple silicon https://formulae.brew.sh/formula/imageoptim-cli#default

JamieMason commented 2 years ago

I've not had any time to check but I suspect the package needs building for a different version of node.js than it is currently or it seems like maybe homebrew also supports linux now(?) and, if that's the case, could be related to this package being mac only.

3zzy commented 2 years ago

https://formulae.brew.sh/formula/imageoptim-cli is now 3.0.7 but I still don't see support for Apple Silicon mentioned there, and of course it doesn't install:

imageoptim-cli: The x86_64 architecture is required for this software.
Error: imageoptim-cli: An unsatisfied requirement failed this build.

Installing via NPM is no different:

zsh: bad CPU type in executable: imageoptim

levibuzolic commented 2 years ago

get the same as above for homebrew, but I was able to install imageoptim-cli via Yarn without issue on Apple Silicon.

$ yarn global add imageoptim-cli

  yarn global v1.22.17
  [1/4] 🔍  Resolving packages...
  [2/4] 🚚  Fetching packages...
  [3/4] 🔗  Linking dependencies...
  [4/4] 🔨  Building fresh packages...
  success Installed "imageoptim-cli@3.0.7" with binaries:
        - imageoptim
  ✨  Done in 5.25s.

Looks like the homebrew formula needs to be updated: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/imageoptim-cli.rb#L23

janosh commented 2 years ago

@levibuzolic Does it actually run after yarn installation?

levibuzolic commented 2 years ago

@janosh yes, runs without issue.

$ imageoptim --imagealpha --quality 0-100 --number-of-colors 32 example.PNG
i Running ImageAlpha...
i Running ImageOptim...
✓ example.PNG was: 474kB now: 47.7kB saving: 426kB (89.93%)
✓ TOTAL was: 474kB now: 47.7kB saving: 426kB (89.93%)
✓ Finished

$ which imageoptim
/Users/levi/.npm-global/bin/imageoptim

$ ls -lah /Users/levi/.npm-global/bin/imageoptim
lrwxr-xr-x 1 levi staff 54 Feb 15 12:52 /Users/levi/.npm-global/bin/imageoptim -> ../../.config/yarn/global/node_modules/.bin/imageoptim*

$ arch
arm64
janosh commented 2 years ago

@levibuzolic Thanks! Can you confirm that it's using Rosetta?

levibuzolic commented 2 years ago

Yep.

image

JamieMason commented 2 years ago

Anything I need to do for this? I don't own an M1 Mac.

Spomsoree commented 2 years ago

I'm currently getting the same error with the brew install

imageoptim-cli: The x86_64 architecture is required for this software.

ickc commented 2 years ago

@Spomsoree, if you follow https://github.com/Homebrew/homebrew-core/pull/96368 then you'll see the patch isn't accepted, and is made under the assumption that you can run it through rosetta 2.

So in short, it can't be run native yet, but you can run it through rosetta 2. In order to do this, follow https://github.com/Homebrew/brew/issues/9173

jasonhibbs commented 2 years ago

Similar issues to above, but with Yarn I get:

$ imageoptim --imagealpha --quality 0-100 --number-of-colors 32 example.PNG
zsh: bad CPU type in executable: imageoptim

$ which imageoptim
/Users/jason/.yarn/bin/imageoptim

$ ls -lah /Users/jason/.yarn/bin/imageoptim
lrwxr-xr-x  1 jason  staff    54B 10 Oct 17:25 /Users/jason/.yarn/bin/imageoptim -> ../../.config/yarn/global/node_modules/.bin/imageoptim

$ arch
arm64

EDIT: turns out, I hadn’t installed rosetta yet – all good after this.

softwareupdate --install-rosetta
sammcj commented 2 years ago

Just hit this problem as well - it's definitely not resolved @JamieMason.

Note - If you use it with Rosetta it'll run in emulation mode which is not efficient, the software needs to be compiled for ARM.

ickc commented 2 years ago

@sammcj, I know you're confused, but this issue is about installing on Apple Silicon, not running it natively. People above showed that it can be installed, so indeed this issue is resolved.

The comment I made is about the brew formula. The maintainer here tried to fix it, but clearly wasn't very familiar with homebrew. And technically it is an issue for homebrew, not this repo (homebrew formula are individually maintained, sometimes by the same developer of the software, but most of the time not, as in any other package index.)

Regarding running it natively, probably you should worry more about this issue: https://github.com/ImageOptim/ImageOptim/issues/334

Lastly, it is easy to ask for people to "just recompile for arm64". But remember this is all free softwares developed by people in their free time and volunteer to release it with an open source license. Most these licenses come with a clause saying that the software has no warranty. They have no obligation at all to do those volunteer work. So just be nice and stop behaving like a consumer.

sammcj commented 2 years ago

@ickc that's a bit petty / high and mighty, I'm an OSS maintainer as well. While I appreciate what you're saying in general - I didn't like a consumer - I just stated that it's not fixed and needs to be compiled for ARM plain and simple 🤷

ickc commented 2 years ago

@sammcj, which part of the issue "Unable to install on M1 / Apple Silicon" you think is not closed/resolved?

Feel free to open a new issue if you want.

And have you visited the linked issue? It seems like you're not really reading what I wrote, nor understanding what is really the issue at hand. And given your attitude I'll refrain from commenting here further.

cobyism commented 1 year ago

Friendly bump: We're ~9 months on since last activity here, but this is still an issue.

When I attempt to brew install imageoptim-cli on Apple Silicon (M2), I get the message:

$ brew install imageoptim-cli
[…snip…]
imageoptim-cli: The x86_64 architecture is required for this software.
Error: imageoptim-cli: An unsatisfied requirement failed this build.

The version pulled down by yarn seems to run fine:

$ yarn add imageoptim-cli
[…snip…]
✨  Done in 0.50s.

$ node_modules/imageoptim-cli/dist/imageoptim --version
3.0.7

What, specifically, are the blockers to updating the homebrew formula?

chenrui333 commented 1 year ago

it looks like it is not installing the arm native artifact

  imageoptim-cli
    * Binaries built for a non-native architecture were installed into imageoptim-cli's prefix.
      The offending files are:
        /opt/homebrew/Cellar/imageoptim-cli/3.1.7/libexec/lib/node_modules/imageoptim-cli/dist/imageoptim

See this PR, https://github.com/Homebrew/homebrew-core/pull/135595 The build log is in here, https://github.com/Homebrew/homebrew-core/actions/runs/5437629545/jobs/9888363914

intmainreturn00 commented 1 year ago

Also don't work for me:

> brew install imageoptim-cli
imageoptim-cli: The x86_64 architecture is required for this software.
Error: imageoptim-cli: An unsatisfied requirement failed this build.

maybe this should be reopen?

inspiredearth commented 1 year ago

Also don't work for me:

> brew install imageoptim-cli
imageoptim-cli: The x86_64 architecture is required for this software.
Error: imageoptim-cli: An unsatisfied requirement failed this build.

maybe this should be reopen?

Ask far as I've understood from the responses to this thread (started be me), it was determined (here) that since it can be installed if Homebrew is installed in Rosetta mode, the issue is resolved.

I have been using Homebrew for a few years in native Silicon mode, and having to reinstall my Homebrew and all packages (in Rosetta mode) seems like too much hassle just to get imageoptim-cli working. So I've moved on from trying to use imageoptim-cli via Homebrew.

I understand from comments in this discussion that we can install Yarn (a Javascript package manager) via Homebrew (or via Shell script), and then install imageoptim-cli with yarn. I've not yet tried that.

sammcj commented 1 year ago

Yeah running software in emulation is a workaround/hack especially for something that's processor or GPU intensive, but I'm aware Jamie is doing a complete rewrite of imageOptim so probably isn't investing time in the current codebase.