johnlindquist / kit

Script Kit. Automate Anything.
https://scriptkit.com
MIT License
3.91k stars 138 forks source link

run official script failed, node_modules not found #1297

Open crazyxhz opened 1 year ago

crazyxhz commented 1 year ago
image

but node_modules do exist in .kenv folder

image
johnlindquist commented 1 year ago

Can you see if "re-linking" fixes it?

cd ~/.kenv && ~/.knode/bin/npm i ~/.kit
crazyxhz commented 1 year ago

not working

johnlindquist commented 1 year ago

Hmm, could you try this? This may be an issue related to using npx @johnlindquist/install-kit prior to the app download:

CleanShot 2023-07-01 at 08 02 36

crazyxhz commented 1 year ago

repair is hang on nodejs download againπŸ˜…

image
johnlindquist commented 1 year ago

@crazyxhz in your ~/Library/Logs/Kit/main.log do you see using proxy? It should log that out if it detected a proxy env var.

You could also try export HTTPS_PROXY=your proxy open /Applications/Kit.app for the first time you open it.

  const proxy =
    process.env.HTTPS_PROXY ||
    process.env.https_proxy ||
    process.env.HTTP_PROXY ||
    process.env.http_proxy;
  if (proxy) {
    log.info(`Using proxy ${proxy}`);
    options.agent = new HttpsProxyAgent({
      keepAlive: true,
      keepAliveMsecs: 1000,
      maxSockets: 256,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      proxy,
    });
  }
crazyxhz commented 1 year ago

main.log

after

export HTTPS_PROXY=your proxy open /Applications/Kit.app

the repair window show up a second then disappear, the tray icon is busy and not responding, check the log file for more info

image
johnlindquist commented 1 year ago

@crazyxhz just to be clear, you replaced "your proxy" with your actual proxy, right? πŸ˜…

Also, quit and remove the ~/.kit and ~/.knode directories before attempting to open it again

crazyxhz commented 1 year ago

@johnlindquist sure I know what proxy is

removed rm -rf ~/.kit ~/.knode still not working

[2023-07-01 23:24:23.726] [info]  undefined: 🟒 start idle Prompt
[2023-07-01 23:24:23.727] [error] ERROR {
  error: 'Error: spawn /Users/crazyxhz/.knode/bin/node ENOENT\n' +
    '    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)\n' +
    '    at onErrorNT (node:internal/child_process:476:16)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:82:21)\n' +
    '    at runNextTicks (node:internal/process/task_queues:64:3)\n' +
    '    at listOnTimeout (node:internal/timers:538:9)\n' +
    '    at processTimers (node:internal/timers:512:7)'
}
[2023-07-01 23:24:23.729] [error] πŸ‘‹ Ask for help: https://github.com/johnlindquist/kit/discussions/categories/errors
[2023-07-01 23:24:23.730] [info]  πŸ‘€ Status: {"status":"warn","message":""}
[2023-07-01 23:24:23.731] [info]  🎨 Tray status: warn
[2023-07-01 23:24:23.731] [info]  🎨 Tray icon: warn
[2023-07-01 23:24:23.732] [info]  No need to add idle processes
[2023-07-01 23:24:23.732] [info]  DISCONNECT
[2023-07-01 23:24:23.733] [info]  CLOSE
[2023-07-01 23:24:25.606] [warn]  Error: EPERM: operation not permitted, mkdir '/Users/crazyxhz/.knode'
    at /Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:562715
    at l (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:530629)
    at Generator.<anonymous> (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:531967)
    at Generator.throw (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:530992)
    at Kd (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:536621)
    at s (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:536862)
[2023-07-01 23:24:26.110] [info]  Show App: /Users/crazyxhz/.kit/cli/info.js
[2023-07-01 23:24:26.112] [info]  πŸƒβ€β™€οΈ Run /Users/crazyxhz/.kit/cli/info.js
[2023-07-01 23:24:26.113] [info]  Ensure idle process
[2023-07-01 23:24:26.114] [info]  undefined: 🏎 /Users/crazyxhz/.kit/cli/info.js 
[2023-07-01 23:24:26.116] [info]  Another script is already controlling the UI. Denying UI control: info.js
[2023-07-01 23:24:26.117] [error] ERROR {
  error: 'Error: Channel closed\n' +
    '    at new NodeError (node:internal/errors:399:5)\n' +
    '    at ChildProcess.target.send (node:internal/child_process:740:16)\n' +
    '    at /Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:407314\n' +
    '    at l (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:396020)\n' +
    '    at Generator.<anonymous> (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:397358)\n' +
    '    at Generator.next (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:396383)\n' +
    '    at af (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:402780)\n' +
    '    at a (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:402984)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:95:5)'
}
[2023-07-01 23:24:26.119] [error] πŸ‘‹ Ask for help: https://github.com/johnlindquist/kit/discussions/categories/errors
[2023-07-01 23:24:26.119] [info]  πŸ‘€ Status: {"status":"warn","message":""}
[2023-07-01 23:24:26.120] [info]  🎨 Tray status: warn
[2023-07-01 23:24:26.120] [info]  🎨 Tray icon: warn
[2023-07-01 23:24:26.219] [info]  Add one idle process
[2023-07-01 23:24:26.223] [info]  πŸ‘Ά Create child Prompt process: undefined  []
[2023-07-01 23:24:26.226] [info]  undefined: 🟒 start idle Prompt
[2023-07-01 23:24:26.227] [error] ERROR {
  error: 'Error: spawn /Users/crazyxhz/.knode/bin/node ENOENT\n' +
    '    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)\n' +
    '    at onErrorNT (node:internal/child_process:476:16)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:82:21)'
}
[2023-07-01 23:24:26.228] [error] πŸ‘‹ Ask for help: https://github.com/johnlindquist/kit/discussions/categories/errors
[2023-07-01 23:24:26.229] [info]  πŸ‘€ Status: {"status":"warn","message":""}
[2023-07-01 23:24:26.230] [info]  🎨 Tray status: warn
[2023-07-01 23:24:26.230] [info]  🎨 Tray icon: warn
[2023-07-01 23:24:26.231] [info]  DISCONNECT
[2023-07-01 23:24:26.232] [info]  CLOSE
[2023-07-01 23:24:26.871] [info]  πŸ‘€ Status: {"status":"busy","message":"Installing Kit SDK..."}
[2023-07-01 23:24:26.872] [info]  🎨 Tray status: busy
[2023-07-01 23:24:26.882] [info]  🎨 Tray icon: busy
johnlindquist commented 1 year ago

@crazyxhz hmm...

Error: EPERM: operation not permitted, mkdir '/Users/crazyxhz/.knode'

Curious why the account wouldn't have permission to create the ~/.knode dir πŸ€”

johnlindquist commented 1 year ago

Btw, I really appreciate you taking the time to report all of this. It's super useful.

I think we're at the point I need to set up a proxy and test it myself

johnlindquist commented 1 year ago

@crazyxhz Alright, so I set up a proxy on my mac mini with "squid" on my local network at http://192.168.1.50:3128, then tested with this command:

HTTPS_PROXY=http://192.168.1.50:3128 open /Applications/Kit.app

I confirmed it didn't work when not using the correct proxy, then that it did work using the proper URL and port.

Here's the final build (I pushed it to the main site):

https://github.com/johnlindquist/kitapp/releases/tag/v1.77.8

🚨 Note: If your ~/.knode, ~/.kit, and ~/.kenv dirs were partially created before, please delete them before opening the app so that it can go through the whole process again.

crazyxhz commented 1 year ago

using the latest version still same error [2023-07-10 15:59:41.550] [info] Launching Script Kit 1.77.8 [2023-07-10 15:59:41.551] [info] auto updater detected version: 1.77.8

[2023-07-10 16:02:43.499] [error] πŸ‘‹ Ask for help: https://github.com/johnlindquist/kit/discussions/categories/errors
[2023-07-10 16:02:43.501] [info]  πŸ‘€ Status: {"status":"warn","message":""}
[2023-07-10 16:02:43.502] [info]  🎨 Tray status: warn
[2023-07-10 16:02:43.502] [info]  🎨 Tray icon: warn
[2023-07-10 16:02:43.505] [info]  No need to add idle processes
[2023-07-10 16:02:43.509] [info]  DISCONNECT
[2023-07-10 16:02:43.510] [info]  CLOSE
[2023-07-10 16:02:44.926] [error] Error: EPERM: operation not permitted, mkdir '/Users/crazyxhz/.kit'
[2023-07-10 16:02:45.380] [warn]  Error: EPERM: operation not permitted, mkdir '/Users/crazyxhz/.knode'
    at /Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:563752
    at l (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:531357)
    at Generator.<anonymous> (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:532695)
    at Generator.throw (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:531720)
    at Kd (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:537349)
    at s (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:537590)
[2023-07-10 16:02:45.885] [info]  Show App: /Users/crazyxhz/.kit/cli/info.js
[2023-07-10 16:02:45.886] [info]  πŸƒβ€β™€οΈ Run /Users/crazyxhz/.kit/cli/info.js
[2023-07-10 16:02:45.887] [info]  Ensure idle process
[2023-07-10 16:02:45.887] [info]  undefined: 🏎 /Users/crazyxhz/.kit/cli/info.js 
[2023-07-10 16:02:45.889] [info]  Another script is already controlling the UI. Denying UI control: info.js
[2023-07-10 16:02:45.890] [error] ERROR {
  error: 'Error: Channel closed\n' +
    '    at new NodeError (node:internal/errors:399:5)\n' +
    '    at ChildProcess.target.send (node:internal/child_process:740:16)\n' +
    '    at /Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:407800\n' +
    '    at l (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:396483)\n' +
    '    at Generator.<anonymous> (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:397821)\n' +
    '    at Generator.next (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:396846)\n' +
    '    at af (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:403243)\n' +
    '    at a (/Applications/Kit.app/Contents/Resources/app.asar/main.prod.js:2:403447)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:95:5)'
}
crazyxhz commented 1 year ago

download of node using proxy seems pretty fast. But seems the downloaded node is node installed in ~/.knode which do not exist after Kit inital setup why not using the system already installed node?

johnlindquist commented 1 year ago

@crazyxhz

3 reasons:

  1. The Kit.app "forks" a node process that loads the script. The app node version and process node version need to match or any packages with native installed dependencies will fail.

  2. The app creates wrappers around scripts in the ~/.kenv/bin dir so people can run scripts from the terminal just by command name

  3. The user might not have node installed

question

Are you an admin on your machine?

[2023-07-10 16:02:44.926] [error] Error: EPERM: operation not permitted, mkdir '/Users/crazyxhz/.kit' [2023-07-10 16:02:45.380] [warn] Error: EPERM: operation not permitted, mkdir '/Users/crazyxhz/.knode'

means that Kit.app doesn't have permission to create those directories. I've never seen anyone report that error before, so there must be something unique to your setup that's preventing Kit.app from creating them.

crazyxhz commented 1 year ago

@johnlindquist what user kit is running at? I'm the admin of the machine and I can mkdir in the home directory

image
johnlindquist commented 1 year ago

@crazyxhz It doesn't change users πŸ€”.

Maybe because it's running with the open command to assign the HTTPS_PROXY env var and open is somehow running under a different user? πŸ€” That doesn't really make sense to me, but I'm kinda reaching at this point...

note: I am working on fixing up @johnlindquist/install-kit based on the issues you found and hope to have it all updated tomorrow.