Closed codergautam closed 8 months ago
Aren't node system commands supposed to be called from the main process? This seems unrelated to electron-builder, which is simply a packager (not a compiler or bundler).
Sorry, typo on my end. I did mean main process (src/main.ts file)
I am having this exact same problem. npm start
works just fine, but npm build
produces a "command not found" error. I am on a mac trying to reach Ollama via Cl
Yeah trying to find a workaround for this and will post here, let me know if you find anything @betterbrand
Try logging what process.env
is and check that your executable is accessible via PATH var or any other env vars you may need. You may need to provide a direct path to the executable, similar to the /bin/bash
logic that exists for RPM and Deb updaters, albeit it is using spawn
.
https://github.com/electron-userland/electron-builder/blob/6b84010b67de0ddc07404d53436bbfbfa2761f88/packages/electron-updater/src/RpmUpdater.ts#L30-L64
Try logging what
process.env
is and check that your executable is accessible via PATH var or any other env vars you may need. You may need to provide a direct path to the executable, similar to the/bin/bash
logic that exists for RPM and Deb updaters, albeit it is usingspawn
.
Thank you! Trying this now
@mmaietta @codergautam before building I get two different responses to the path.
npm start
returns:
/Users/myname/Documents/GitHub/Morpheus/node_modules/.bin:/Users/myname/Documents/GitHub/node_modules/.bin:/Users/myname/Documents/node_modules/.bin:/Users/myname/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/myname/google-cloud-sdk/y/google-cloud-sdk/bin:/Users/myname/anaconda3/bin:/Users/myname/anaconda3/condabin:/Users/myname/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/myname/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Applications/Conveyor.app/Contents/MacOS://Users/myname/Desktop/flutter/bin://Users/myname/StudioProjects/flutter/bin
yarn start
returns
/var/folders/9h/6xxs5cm509n1k0l80kln6q8h0000gn/T/yarn--1700602882940-0.31378766444904027:/Users/myname/Documents/GitHub/Morpheus/node_modules/.bin:/Users/myname/.config/yarn/link/node_modules/.bin:/Users/myname/.yarn/bin:/opt/homebrew/Cellar/node/21.1.0/libexec/lib/node_modules/npm/bin/node-gyp-bin:/opt/homebrew/Cellar/node/21.1.0/lib/node_modules/npm/bin/node-gyp-bin:/opt/homebrew/Cellar/node/21.1.0/bin/node_modules/npm/bin/node-gyp-bin:/Users/myname/google-cloud-sdk/y/google-cloud-sdk/bin:/Users/myname/anaconda3/bin:/Users/myname/anaconda3/condabin:/Users/myname/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/myname/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Applications/Conveyor.app/Contents/MacOS://Users/myname/Desktop/flutter/bin://Users/myname/StudioProjects/flutter/bin
Note: yarn start
shows /var/folders/9h/6xxs5cm509n1k0l80kln6q8h0000gn/T/yarn--1700602882940-0.31378766444904027:
before the list of User directories
I meant to check the difference in process.env
between runtime npm start
and the bundled electron app. Doesn't matter what the diff is between yarn and npm, only matters what the bundled electron app is able to access
@mmaietta @codergautam @paulrosania These are the two different log files. I'm new to this – I really appreciate your patience and guidance.
FWIW and Just to be complete, I have tried this with forge as well.
process_env_forge_packaged.log process_env_forge_runtime.log
Checking for differences now Thanks again
PATH in runtime (npm run start)
PATH: '/Users/myname/Documents/GitHub/Morpheus/node_modules/.bin:/Users/myname/Documents/GitHub/node_modules/.bin:/Users/myname/Documents/node_modules/.bin:/Users/myname/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/myname/google-cloud-sdk/y/google-cloud-sdk/bin:/Users/myname/anaconda3/bin:/Users/myname/anaconda3/condabin:/Users/myname/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/myname/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Applications/Conveyor.app/Contents/MacOS://Users/myname/Desktop/flutter/bin://Users/myname/StudioProjects/flutter/bin',
And PATH when packaged (npm run build)
PATH: '/usr/bin:/bin:/usr/sbin:/sbin',
When running npm run start
, it is executing in your current terminal environment, which has all the settings of .profile
/.bash_profile
/.zshrc
/etc. loaded.
A packaged application doesn't have access to your user-profile
Is it possible to load these from code?
Anything that is loaded from the user's machine may or may not have their user profiles set up in the same way, so I would suggest against trying to load those files from code.
There's a package that might be useful in this context: https://www.npmjs.com/package/python-shell
That all being said, I don't know of a reliable way to load pip from within the app without it already being in the PATH.
No it is in Path, just doesnt work when opening the app normally. When right clicking the app, pressing view package contents, navigating to the Terminal iconed app and opening that works perfectly fine. (It shows a log of the app while its running) @mmaietta
Anyways will be investigating this, will post an update if I find anything.
@codergautam i am having the same problem. Have you found any solution to make the command recognizable in the packed app?
@elianbraja No not atm, will be investigating more this week and will post if I find any fix
@codergautam I ended up generating a binary file and calling that file instead. You can create a Python executable file with “pyinstaller”. This way you can directly execute the script just by referencing it to exec.
Interesting will try it out, my issue is I need to call pip to check some current packages. Maybe I can try rewriting that in Python and calling that executed program.
Seems to be related to #6726 in some way.
I'm trying to run some pip commands from my electron app using exec
(but same/similar issue with spawn and execa module as well)
Steps to reproduce:
Image:
I think for some reason it's trying to run the python 2.7 stuff which was removed. This is a major blocker, any way to fix?