Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install script for Raspberry Pi may disable/damage some existing nodejs installations #24

Open
toggledbits opened this issue Jan 7, 2022 · 3 comments

Comments

@toggledbits
Copy link

Current Behavior

Preconditions: nodejs has been installed by means other than the Node-RED installer and its bin files linked into /usr/local/bin.

If you run the install script for the Raspberry Pi without any of the options to install a particular version of nodejs, that is, direct it to use an existing installation of nodejs already on the system, the install script will remove the node and npm commands from the system if they are installed in /usr/local/bin, thus damaging the existing nodejs installation. This also then prevents Node-RED from starting successfully when node-red-start is attempted, because it then cannot find node or npm:

image

The deletion of the files occurs at line 338:

sudo rm -rf /usr/local/lib/node_modules/node-red* /usr/local/lib/node_modules/npm /usr/local/bin/node-red* /usr/local/bin/node /usr/local/bin/npm 2>&1 | sudo tee -a /var/log/nodered-install.log >>/dev/null

Expected Behavior

The script should not remove executables that it didn't previously install. It seems to assume that any node and npm files installed in /usr/local/bin are its own from a previous install, but this seems a bit broad.

Steps To Reproduce

Install any version of nodejs using their recommended instructions. After that, link the installed executables into /usr/local/bin. Some systems may do this with their own package installers.

Then run the RPi Node-RED install script per the instructions as shown (with no option to install a particular version of node).

Example flow

N/A

Environment

  • Node-RED version: 2.1.4
  • Node.js version: any
  • npm version: any
  • Platform/OS: *nix
  • Browser: N/A
@toggledbits toggledbits changed the title Jan 7, 2022
@dceejay
Copy link
Member

dceejay commented Jan 7, 2022

Currently the script only tries to uninstall them if they are not a suitable version (so currently 12 or greater). What should it do if it find a version in usr/local/bin ? Just abort and tell the user to uninstall it themselves ? If we don't uninstall it we cannot proceed as the usr/local/bin version will take precedence and then Node-RED will not be in a runnable state.

@toggledbits
Copy link
Author

Maybe you're looking at a different version of the script than I am, but the line I referenced is outside the test for old version (which appears to be a block beginning at line 271 and ending at 300, well before the line that removes the files). In fact, the only thing restricting the execution of line 338 (the removal from /usr/local/bin) is the case/test at 209 where the user indicates that it's OK to proceed.

And in any case, I was using nodejs 16.13 during the run, which is supported, so the low-version branch would not apply.

@knolleary knolleary transferred this issue from node-red/node-red Jan 12, 2022
@knolleary
Copy link
Member

I have moved this issue over to the linux-installer repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants