Shopify / node-themekit

Theme asset interaction library and management tools written in Node.js
MIT License
114 stars 25 forks source link

Apple M1 build crashes when trying to build dependency of themekit #78

Open aamistad opened 3 years ago

aamistad commented 3 years ago

Was running into this issue trying to setup my dev environment on a new mac mini. Not sure if its something on my end or something that needs to be updated.


[6/15] ⠠ gifsicle
[9/15] ⠠ pngquant-bin
[7/15] ⠠ mozjpeg
[4/15] ⠠ @shopify/themekit
error /Users/andrewamistad/Sites/dry-farm-wines/node_modules/@shopify/themekit: Command failed.
Exit code: 1
Command: node ./lib/cli.js install
Arguments:
Directory: /Users/andrewamistad/Sites/dry-farm-wines/node_modules/@shopify/themekit
Output:
-/Users/andrewamistad/Sites/dry-farm-wines/node_modules/@shopify/themekit/lib/install.js:46
        throw runErr;
        ^

Error: The `/Users/andrewamistad/Sites/dry-farm-wines/node_modules/@shopify/themekit/bin/theme` binary doesn't seem to work correctly
    at BinWrapper.<anonymous> (/Users/andrewamistad/Sites/dry-farm-wines/node_modules/bin-wrapper/index.js:156:7)
    at ChildProcess.<anonymous> (/Users/andrewamistad/Sites/dry-farm-wines/node_modules/bin-check/index.js:26:4)```
andyw8 commented 3 years ago

@aamistad Do you have your Terminal set to 'Open using Rosetta'?

https://developer.apple.com/documentation/apple_silicon/about_the_rosetta_translation_environment

aamistad commented 3 years ago

@andyw8 yes terminal is set to open using Rosetta. I've also attempted reinstalling themekit, brew and reinstalled command line tools

tanema commented 3 years ago

~Please open this on the https://github.com/Shopify/node-themekit repo as it looks like an installation issue with the node library. We have seen success with others using themekit directly on M1~

I have learned that I can transfer issues now :D

erickzhao commented 3 years ago

Stack trace indicates that this is an error with the bin-check call on Line 133 of the bin-wrapper dependency.

I don't have access to an M1 machine right now, but it'd be useful to debug by seeing what bin-check is returning.

As per usage docs:

const binCheck = require('bin-check');

binCheck('/path/to/themekit/binary', ['--version']).then(works => {
    console.log(works);
    //=> true
});
pierreverrier commented 3 years ago

Running into the same issue.

@erickzhao I've tried running the binary and received the following message:

[1] 6631 segmentation fault

Not quite sure what to make of it. Any advice on next steps?

1aurabrown commented 3 years ago

Has anyone solved this problem yet? I receive the following error when I yarn install a project with themekit as a dependency:

error /Users/laurabrown/work/simonmiller/node_modules/@shopify/themekit: Command failed.
Exit code: 1
Command: node ./lib/cli.js install
Arguments: 
Directory: /Users/laurabrown/work/simonmiller/node_modules/@shopify/themekit
Output:
-/Users/laurabrown/work/simonmiller/node_modules/@shopify/themekit/lib/install.js:46
        throw runErr;
        ^

Error: The `/Users/laurabrown/work/simonmiller/node_modules/@shopify/themekit/bin/theme` binary doesn't seem to work correctly
    at BinWrapper.<anonymous> (/Users/laurabrown/work/simonmiller/node_modules/bin-wrapper/index.js:156:7)
paul-muckypuddle commented 3 years ago

Also experiencing this issue on an M1 Macbook Pro. Happy to run any commands / tests to assist in getting this fixed.

paul-muckypuddle commented 3 years ago

Running the downloaded theme file from command line gives a segmentation fault.

paul-muckypuddle commented 3 years ago

@erickzhao Running using this code:

const binCheck = require('bin-check');

binCheck('theme', ['--version']).then(works => {
    console.log(works);
    //=> true
}).catch(err => {
    console.log(err)
});

gives:

paul@pauls-mbp test2 % node main.js
{ Error: spawn theme ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn theme',
  path: 'theme',
  spawnargs: [ '--version' ],
  killed: false,
  stdout: '',
  stderr: '',
  failed: true,
  signal: null,
  cmd: 'theme --version',
  timedOut: false }
paul-muckypuddle commented 3 years ago

Downloading https://shopify-themekit.s3.amazonaws.com/v1.1.2/darwin-amd64/theme directly (URL taken from the brew themekit installer output), then making it executable, works.

paul-muckypuddle commented 3 years ago

Using that executable in my previous test (and changing the argument to simply version) also works

paul-muckypuddle commented 3 years ago

Digging a bit deeper - when downloaded and made executable, the last 0.X version (0.6.12) segfaults, and the first 1.X version 1.0.0 doesn't, so imagine there's been some change here? File size difference between the 2 is significant.

I'm guessing the original submitter, like me, is using an earlier version of themekit as part of Slate v0, where the desired version of this package required by slate-tools is 0.6.6 (see https://github.com/Shopify/slate-tools/blob/master/package.json)

paul-muckypuddle commented 3 years ago

And a bit deeper - looks like even the latest (last) release of Slate, v1.0.0 beta 19, uses @shopify/themekit 0.6.12 - the corresponding themekit binary from AWS (v0.6.12) segfaults, but themekit v1.0.0 does not - works fine. Is it possible to get those earlier binaries not segfaulting?

tanema commented 3 years ago

Is it possible to get those earlier binaries not segfaulting?

No, they are built on older versions of Go with incompatible functionality for newer versions of Go. They segfault because of this reason.

paul-muckypuddle commented 3 years ago

Gotcha. So as it stands no version of Slate can run on M1 chips due to the dependency on themekit 0.6.12 and its binaries.

I'm reaching the limits of my knowledge on these things - any potential suggestions for how to get Slate (which I appreciate is now obsolete, but with no official replacement) to use a version of tk >= 1.0.0?

tanema commented 3 years ago

Yes unfortunately, it looks like the best option is for you to fork slate and update the tk version in the package.json

camwhite commented 3 years ago

I've tried forking and manually upgrading @shopify/themekit to v1.1.6 and still seeing the same error. Anyone have any success with this yet?

aydinsenturkk commented 3 years ago

I still haven't found a solution for this problem. Can anyone solve it?

aamistad commented 3 years ago

Still haven't been able to come up with a solution yet :(

tiny-organics commented 3 years ago

This may be related: when setting up themekit on a new macbook pro I get the error "SHA already in use" when trying to install themekit using homebrew. I've even searched within the file and there is no matching SHA key at all. I cannot get around this issue, I haven't removed homebrew as it works fine otherwise.

On Wed, Jan 27, 2021 at 9:51 PM aamistad notifications@github.com wrote:

Still haven't been able to come up with a solution yet :(

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Shopify/node-themekit/issues/78#issuecomment-768797855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMAWWCHFKZV2A3A376PW42LS4DUL3ANCNFSM4UFDEUDA .

--

Mirna Plakalović | Frontend Engineer

386 Park Ave South, 5th Floor, NYC

M: +1 201 952 3929

[image: Instagram] https://www.instagram.com/tinyorganics/ [image: Facebook] https://www.facebook.com/Tiny-Organics-406584639749282/ [image: Pinterest] https://www.pinterest.com/tinyorganics/

Use my Friends & Family code for 25% off your first box: MIRNALOVESYOU25

anthony-gordon-shopify commented 3 years ago

Any updates on this?

Edit: Manually updating the package.json of the project to modify the version of themekit seemed to work.

"@shopify/themekit": "1.1.7",

zibs commented 3 years ago

Any luck here?

erickzhao commented 3 years ago

Edit: Manually updating the package.json of the project to modify the version of themekit seemed to work.

If this is the case, #92 should have resolved this problem. I'm not sure who has access to publishing the NPM package but I reckon you'd want to test with the upcoming v1.1.8 release of this package.

kgea commented 3 years ago

For anyone still not able to figure this out. Check out this solution. It worked for me and my local updates finally started to upload to shopify for me to test locally, the correct way. https://github.com/Shopify/slate/issues/1107

It also fixed an error from not showing unknown command "[object Object]" for "theme"

========== STEPS I took ============

1) Updated packages.json file line"@shopify/themekit": "^0.6.12", to be "@shopify/themekit": "^1.1.7", and added a resolution after dependencies. "resolutions": { "**/@shopify/themekit": "^1.1.7" }, That way it would force yarn to use v1.1.9 of themekit instead of v0.6.12.

2) Opened Terminal using the "Open using Rosetta" option.

3) Ran yarn and successfully compiled

4) Ran yarn start but got error unknown command "[object Object]" for "theme" and seemed to be coming from a the slate-sync/index.js line 4: const themekit = require('@shopify/themekit').command;. I removed .command and the error went away after running yarn start but would not upload to shopify to show my local version of the site.

5) I updated the file [theme path]/node_modules/@shopify/slate-sync/index.js to reflect the changes found here: Slate #1107: comment then yarn complied correctly, yarn start started correctly and uploaded to shopify.

bansavage commented 3 years ago

@kgea

Confirming this solution works!! Thank you so much. 🙏 Using an Apple Macbook M1 w/ Big Sur v11.4

rodrigobaezz commented 2 years ago

I keep on having that same issue, unknown command "[object Object]" for "theme", the only difference being that im using @shopify/slate-tools@0.14.0 which doesn't have a slate-sync folder for me to apply the changes proposed here Slate #1107: comment.

Does anybody know what to do in that case?

celsowhite commented 2 years ago

@kgea solution fixed it for me. I ended up including the modified slate-sync as a local npm package so any future installs wouldn't overwrite the file fix. Also using yarn is important rather than npm to get the resolutions feature. See below for what my package.json looks like. To get a local version of slate-sync copy it from node_modules and include it in a folder in your theme. I typically don't recommend doing that but since its very deprecated it should be ok.

{
  "name": "slate",
  "version": "1.1.4",
  "description": "",
  "scripts": {
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@shopify/slate-tools": ">=1.0.0-beta.19",
    "@shopify/slate-sync": "file:src/scripts/vendor/slate-sync",
    "@shopify/themekit": "^1.1.7"
  },
  "resolutions": {
    "**/@shopify/themekit": "^1.1.7",
    "**/@shopify/slate-sync": "file:src/scripts/vendor/slate-sync"
  }
}
lukechadwick commented 2 years ago

I've created a drop-in M1 compatible fork of slate-tools here if anyone else has this issue https://github.com/lukechadwick/slate-tools-m1

jameshalldev commented 2 years ago
  1. @shopify/themekit": "

Thank you kgea!

This worked for me on macOS Monterey 12.4, MacBook Pro (13-inch, M1, 2020) Apple M1