Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
439 stars 130 forks source link

[Bug]: shopify app init just hangs, it's neither completing nor throwing an error #4869

Open i-haz-teh-codez opened 1 week ago

i-haz-teh-codez commented 1 week ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

App

Expected behavior

Command shopify app init should either set up a new app or return an error.

Actual behavior

The command just hangs. No response for 30+ minutes. Neither a new app is set up nor an error returned.

I asked for assistance on StackOverflow. Here's the link to the question.

Verbose output

See 'Actual behavior' above. No output is being returned.

Reproduction steps

  1. Install NVM (0.40.1)
  2. Install Node LTS (22.11.0) with NPM (10.9.0)
  3. Install Shopify CLI (3.70.0) globally
  4. Run shopify app init

Operating System

Ubuntu 22.04

Shopify CLI version (check your project's package.json if you're not sure)

3.70.0

Shell

bash

Node version (run node -v if you're not sure)

22.11.0

What language and version are you using in your application?

Node 22.11.0

isaacroldan commented 1 week ago

Hi @i-haz-teh-codez, seems like the CLI hangs during Installing dependencies... which is the CLI shelling out to npm to install the template dependencies. Can you try the same command with the --verbose flag and post the output here?

Also, could you try maybe with a different package manager and/or node version?

i-haz-teh-codez commented 1 week ago

Ah, there's a --verbose flag I was unaware of. But I'm not seeing how it changes anything. I mean, you've nailed where the problem is (hanging at "Installing dependencies with NPM...") which is where the verbose output ends and the hanging starts. In other words, there's no more verbose output after that installing dependencies stage — the verbosity ends right there.

Also what's the point of switching to a different package manager when it's supposed to work with LTS Node? By the way, I got it to work with Node 20.18.0 but surely that's not ideal — it should be working with the latest stable Node 22.11.0?

Anyway, here's the --verbose output. I updated my question on StackOverflow with the logs but was unable to link to the photos here (hotlinking error). Check them out there.

i-haz-teh-codez commented 1 week ago

I retried again in a separate terminal window. Still hanging even right now, almost 2 hours later. Here's the --verbose output:

Here are the relevant first lines...

Image

And the relevant last lines...

Image

isaacroldan commented 1 week ago

Also what's the point of switching to a different package manager when it's supposed to work with LTS Node?

Just trying to pin down where the issue is. I tried with node 22, npm and linux and it worked for me 🤔

I assume that running npm install in any other project works as expected?

Could you check in the folder from the verbose log: /tmp/..../app and see if it actually installed the dependencies and just failed to report it? If it didn't, can you try running npm install in that directory and see if it works? (maybe is a permissions issue?)

Sorry I don't have more concrete answers, but I can't reproduce the issue

i-haz-teh-codez commented 1 week ago

OK.

I reported that I actually got it working with a lower version of Node. Also I mentioned that's not ideal since I'm supposed to simply run shopify app init and everything should be set up flawlessly.

But now I have to use tricks like downgrading Node or setting things up manually in /tmp when I'm not supposed to be doing all that (even though I'm technically able to). If anything, I was only reporting the CLI is neither completing running the command nor throwing an error. It just hangs — no verbose output, no error — nothing.

I actually opened a new terminal window and attempted the command again minutes after your first comment. Well, that command is still hung up at "Installing dependencies with npm ..." even at this very moment, near 3 hours later.

i-haz-teh-codez commented 1 week ago

Update: In my last comment I mentioned I ran the command again in another terminal window and left it hung up there. I came back to check and apparently the command exited 9 hours later. Here are the logs, and notice I left the command hung up at 12:31 and received a response at 21:11.

Image

Image

Image

Image

Again, I was only reporting a bug. The CLI hanging and responding 9 hours later obviously isn't the intended behavior.

amcaplan commented 5 days ago

The code you're running is here:

https://github.com/Shopify/cli/blob/2450a8059100273c8c8ec0b00be2860ed2bde05b/packages/app/src/cli/services/init/init.ts#L173-L184

getDeepInstallNPMTasks really just runs npm install, see here:

https://github.com/Shopify/cli/blob/2450a8059100273c8c8ec0b00be2860ed2bde05b/packages/app/src/cli/services/init/template/npm.ts#L58-L76

It looks like npm install actually took 9 hours. I'm clueless as to why, but it's not something the CLI can control.

If you'd like to confirm, you can do this again and scan running processes for npm install (ps aux | grep npm).