-
Notifications
You must be signed in to change notification settings - Fork 401
Improved handling of node installation (& miscellaneous improvements) #1419
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
Improved handling of node installation (& miscellaneous improvements) #1419
Conversation
|
Was this designed for and tested on a Raspberry Pi rig? I recently re-flashed and reinstalled all my Edison rigs using |
Yes, this was designed for and tested on a Pi rig (A Pi Zero W, to be precise). Even if the JS changes are not needed for Edison, my hope and expectation is that these changes provide an equally effective solution that would reduce the need to treat the two platforms differently. Edit: With that said, I believe there is still some work to be done to make it work ideally for both. @cluckj mentioned in another comment that the latest version available through |
|
Ok. LMK when y'all have tested it to your satisfaction on the Pi, and I can re-flash and test it on an Edison. |
|
I have spent some time thinking about this, and I would appreciate your input on the following: For our two major architectures, x86 (Edison) and armv6 (Pi 0W), their support was downgraded to "Experimental" as of versions 10 and 12, respectively. So, (On that note, @cluckj can you check and see what the output of I suppose there is no harm in using these old versions and we can leave it at that, but I do want to throw out an alternative for consideration: Use unofficial builds when they are available (with the old but technically supported versions as a fallback). I believe Regardless of the decision on that matter, this PR should be ready to move once the following changes are made:
|
|
Hi Chance, unfortunately this build failed on the rpi zero 2. Had exactly the same issues with crashing with each attempt at an npm install. I have the version of npm as 8.1.2 which is failing with node version 10.24. Global install of latest node via n prior to starting the installation worked. Just wondering about how to do a check for newer hardware to do a check and install most up to date node. |
|
Hi @sharbi!
That version of npm is too new for that version of node. They won't work together. I would be eager to figure out how that version of npm got installed. I don't think Was this tested on a clean image of Raspbian? If Do you happen to have the output of the script during install?
I haven't pushed the change yet, but I think the best solution is to just do |
|
Fresh flash of Raspbian caused the same error. Can't quite figure out how it happens. Output is below: Installing bash completion script /etc/bash_completion.d/python-argcomplete SyntaxError: Invalid or unexpected token Checking versions after running the code shows node 10.24 and unable to see npm version due to node being incompatible. |
|
Hi @sharbi I think I know why it happens. This line of openaps-install.sh does not download the version of My advice: re-test, but instead of piping the install script directly from curl to bash, I would clone the repo, switch to this PR branch (see these GitHub docs for context). The tl;dr is Old line in openaps-install.sh: New line: Once those changes are made, run openaps-install.sh (ideally in a root shell, but it would be interesting to know if there is a pass/fail difference depending on if it is run as root or not) and let's see if it works! Hopefully it is clear what the issue is now and what changes need to be made locally to test them. Ideally this should be a pain point, but we can definitely work on improving this experience if necessary. |
|
Hi cool that all makes sense - should have remembered this from last testing I was doing! Installation works first time, but then fails setup for some other reason (fails with nightscout autoconfigure-device-crud) which feels like a separate issue. Strangely then can't re-run installation. Again n and npm not globally installed and the node version installed was 8.17.0. |
Indeed, that does sound like it would be a separate issue, but impossible to say for sure at this point.
Both the version and the installation status defy my expectations. In the current iteration, If you have the full input/output of a clean installation attempt (e.g. no previous installations) using the scripts from this PR branch, I'd really appreciate it if you could put that in a GitHub Gist and link it here. |
|
Sorry - scrap that. Being a muppet in real time. Solved and now installed with n + node 1. Setup still not working so will need to start work on that... Okay finally sorted - needed to run oref0-setup from local download as well, just kept running the standard setup code. Hopefully would be resolved when these files are merged! Sorry for causing all the confusion, seems to be all good now! |
|
For buster & bullseye you can just 'apt-get install' it.... |
|
@dcacklam Perhaps the issue has resolved itself with time, or the issue was in my/our implementation all along, but when I opened this PR, the repository versions of Certainly, perhaps I've fallen prey to the trap that is added complexity, but I do appreciate the platform-agnostic solution that comes with using something like |
|
@ChanceHarrison Would you like to refactor this to split out the |
The previous command (which installs npm@latest) results in the installation of a version of npm which is almost certainly incompatible with the installed (regardless of source) version of nodejs
- Remove what should be a redundant install, instead opt to fail if node is missing. Given that openaps-packages.sh handles installing node, this failing check indicates an unmitigated failure in the process previously, so let's not continue and make things potentially worse. - Attempt to remove existing nodejs/npm packages using apt - Warn the user if versions of node and npm remain - Switch nvm for n, using installed version of n if available Else, bootstrap install n as done elsewhere.
|
@scottleibrand Consider it done. Refactored, rebased onto upstream/dev, and history is rewritten to clarify the changes that are being proposed. I don't recommend separating the changes any further, but let's talk if you think otherwise. I will have to make the time to grab a spare SD card and try installing OpenAPS from scratch again to test my changes once more. When I do so, I'll be sure to write clear-and-concise testing instructions should others want to do the same (at least until the PR is merged into |
|
I fixed npm and node versions conflict during Openaps 0.7.1 installation: #1434 |
|
Some time ago, I had the opportunity to test these changes with someone who has an Edision rig who had been attempting to do a clean install of oref0. I have a few takeaways that I wanted to note here:
Lines 75 has to be changed from: (as an aside, I think it might be valuable to instead only have a single file that needs to be downloaded to bootstrap the install instead of having the bootstrap script download another bootstrap script. I think there is value to having the bootstrap script install Git and clone the repo as first order of business so that everything that runs afterwards can use files that have already been stored locally) Line 76: To re-iterate, I believe the edit to line 76 can be avoided if the appropriate branch name is provided at runtime, but it doesn't completely remove the need (which would be the goal) of manually editing files. |
|
Testing this now via: |
|
That didn't work. Errored out with: |
@scottleibrand I believe that success is contingent on the state of the system prior to running setup. If you did #1434 (comment) and then ran this, the error is expected. The quick workaround is to uninstall any existing nodejs/npm. Reasoning: You will find that the setup flow with the proposed changes should succeed in the following cases:
Notably, setup does not adequately detect broken nodejs/npm installations NODE_EXECUTION_TIME="$(\time --format %e node -e 'true' 2>&1)"
if [ 1 -eq "$(echo "$NODE_EXECUTION_TIME > 10" |bc)" ]; then
[...prompt the user to uninstall existing node and install with known good process...]I didn't make this the default behavior to avoid fixing what isn't broken (messing with people's existing nodejs/npm installs) , but that might be a worthwhile tradeoff to avoid failed setups. Especially considering that running setup from the current dev/master consistently results in broken nodejs/npm installations We can automate the "uninstall nodejs/npm" workaround early in setup to allow for known-good installation to take place. Do you agree?
|
|
Ok, trying: |
|
That seems to have worked to install node v9.11.2 and 5.10.0, but other stuff I tried with |
|
You can also take a look at https://github.com/nvm-sh/nvm#uninstalling--removal, nvm seems to make it pretty easy to uninstall, mostly just deleting its directory and removing what it added to |
|
This is working a lot better than That might be an install script issue having to do with updated versions of go, or it might be that this rig's SSD is so far gone it can't keep from corrupting files even during install. I'll probably try another flash and fresh install from dev tomorrow. |
Note: This PR has changed somewhat significantly since inception. The "very minor" changes listed below have been removed to keep the focus on changes to node/npm install improvements. The original text otherwise follows, but please see the comments for relevant context.
Summary
Very Minor Changes
NodeJS Changes
nodejsandnpmfrom the package manager, we instead install the node version manager n since in my first attempt to install OpenAPS found the scripts failing due to issues with getting JS setup (particularly with gettingnpmto a proper version and keeping it there). There may be an easier fix, butnseems like a more robust solution. I chosenovernvmbecause of issues withnvmin multi-user/root environments.nis an actual binary and does a proper global install ofnodethat should avoid those issues. I changed the setup script to reflect the preference ofnovernvm. This change also includes a subtle but important modification to the npm self-update command. It now, instead of updating itself to the latest version of npm, it should update itself to the latest version of npm that is compatible with the installed version of node. Trying to install the latest version of npm with our relatively ancient version(s?) ofnodedoes not work.Copy and pasted code comment that I (re)moved (in a recent commit) but wanted to save for posterity:
If you would like me to squash/rebase any of my commits or remove some (perhaps excessive) code comments, I'd be happy to do so.
Please let me know your thoughts/suggestions. I look forward to making future contributions.
Testing
I used this modified code to conduct my own install and it worked well for me (a lot better than regular
devat the moment). Some of these changes are non-functional and could likely be merged separately, but I could understand the desire for some testing around the JS changes. It shouldn't change anything for existing users who re-runoref0-setup.sh; their existing version of node is likely fine.Perhaps contributors that are doing fresh installs (and just updating their rigs) can do so with these changes included?