Shopify / node-themekit

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

Doesn't install correctly on Linux-based operating systems #94

Open MykalMachon opened 3 years ago

MykalMachon commented 3 years ago

Problem

On Linux-based operating systems, @shopify/themekit fails to install correctly. This is because Themekit itself is not installed during the npm install process.

I have a workaround (see More Information below), but ideally, we could automate this by detecting the operating system version, and running the Linux Themekit installation command during the npm install process

Tested and confirmed the issue on WSL 2 Ubuntu, Ubuntu 20.04 LTS, and Pop_OS!

Replication steps

  1. Install @shopify/themekit as part of a repo or globally
  2. Attempt to use Themekit in any way (CLI or Node.js scripts)
  3. Notice the following error log screenshot_of_error

More Information

I have a temporary workaround which involves the following after running npm install in the repo:

  1. Install Shopify themekit conventionally using Shopify's Themekit Linux guide here
  2. verify that Themekit is installed by typing theme in your terminal
  3. note the location of Themekit by running whereis theme in your terminal
  4. navigate to ./node_modules/@shopify/themekit and create a folder called bin, in that folder create a symbolic link to Themekit's installation location (which we noted in step three) ln -s {{ result of step 3 here}}
  5. Rerun your Themekit commands, they should work now
erickzhao commented 3 years ago

I don't have a Linux machine on hand, but is there any reason the post-install script would fail to download the binary for Linux systems?

The binary downloading logic exists for Linux 32-bit and 64-bit:

https://github.com/Shopify/node-themekit/blob/e2d2f88efef40ad79a261ed8280c3b02ad79f372/lib/install.js#L19-L26

and the binaries themselves seem to exist as well on S3: https://shopify-themekit.s3.amazonaws.com/v1.2.0/linux-amd64/theme

MykalMachon commented 3 years ago

@erickzhao , I actually noticed this right after submitting the issue- I just wanted to get this in before I went to bed last night so didn't take much time to source dive beforehand.

I'm at work right now, but will run npm install on one of my affected repos and look for errors during postinstall / install later tonight and report back.

MykalMachon commented 3 years ago

@erickzhao just confirmed that there are no errors logged when installing the package. image

Additionally, now that I know to look, you can tell that nothing is being run on post-install (on windows you watch a progress bar as Themekit is installed)

Is there anything I can do (as someone with access to a Linux machine) to help solve this?

erickzhao commented 3 years ago

I believe you can use npm link to symlink a local install of @shopify/node-themekit to a test repo and try to log what is happening in that post-install script.

I can take a look at this whenever I get around to installing a Linux VM on my Macbook, as well. :)