installer icon indicating copy to clipboard operation
installer copied to clipboard

Cannot find node to check version if app is packed on MacOS

Open develar opened this issue 9 years ago • 6 comments
trafficstars

An app launched by a GUI launcher (Finder, Dock, Spotlight etc.) receives a pretty empty and useless environment, since standard Unix ways of setting variables via e.g. ~/.profile do not work.

http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x

So, code exec('node --version' in the check-node.js doesn't work because node cannot be found (if you run app, not electron ., see #17).

develar avatar Jul 01 '16 17:07 develar

@develar what if we add this script for bash_profile, and then for bashrc, zshrc and others?

grep export $HOME/.bash_profile | while IFS=' =' read ignoreexport envvar ignorevalue; do
  launchctl setenv ${envvar} ${!envvar}
done

alternatively, instead of node --version it can be /usr/local/bin/node --version

azat-co avatar Jul 02 '16 04:07 azat-co

/usr/local/bin/node --version won't work for non-standard installations.

SomeoneWeird avatar Jul 02 '16 06:07 SomeoneWeird

@mikeal This may be blocking, although we could read the relevant files and construct a $PATH to pass to child_process.exec()...

Fishrock123 avatar Jul 04 '16 11:07 Fishrock123

what if we add this script for bash_profile, and then for bashrc, zshrc and others?

Yes, JetBrains IDEs uses this approach: https://github.com/JetBrains/intellij-community/blob/master/platform/util/src/com/intellij/util/EnvironmentUtil.java#L154

https://github.com/JetBrains/intellij-community/blob/master/bin/mac/printenv.py

develar avatar Jul 04 '16 11:07 develar

reconstructing the entire shell environment is going to be hard. we'll also have to recognize that this will end up enabling versions managers which won't actually pick up the installation we currently do. if we go down the route of reconstructing the shell env we'll need to also handle detecting and possibly disabling node version managers.

mikeal avatar Jul 05 '16 19:07 mikeal

IMO, for now having at least the standard path is a good start

azat-co avatar Jul 06 '16 01:07 azat-co