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

error with node related tools when using DEVON_SOFTWARE_PATH #957

Closed
hohwille opened this issue Oct 21, 2022 · 5 comments · Fixed by #934
Closed

error with node related tools when using DEVON_SOFTWARE_PATH #957

hohwille opened this issue Oct 21, 2022 · 5 comments · Fixed by #934
Labels
bug Something isn't working

Comments

@hohwille
Copy link
Member

This issue might be related to PR #934 that I tested this on:

*** Setting up npm ***
doInstall nodejs  silent  /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node
Cloning or updating download mirrors
Already up to date.
Resolved latest version of nodejs to v19.0.0 from /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/mirrors/nodejs/available-versions
doInstall npm    /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm
Cloning or updating download mirrors
Already up to date.
Resolved latest version of npm to 9.0.0 from /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/mirrors/npm/available-versions
Starting installation of npm in version 9.0.0 to /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm
Software npm seems to be already available in /Users/hohwille/projects/software/default/npm/9.0.0
Linking /Users/hohwille/projects/software/default/npm/9.0.0 to /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm
ln: /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm: No such file or directory
Trying to verify installation of npm (npm -v)
8.19.2
Success: verify installation of npm (npm)
cp: /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm/bin/npm: No such file or directory
cp: /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm/bin/npm.cmd: No such file or directory
cp: /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm/bin/npx: No such file or directory
cp: /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node/node_modules/npm/bin/npx.cmd: No such file or directory
Command 'npm setup' failed with exit code 1

******** ATTENTION ********
Failed to run devon npm setup
We are sorry for the inconvenience. Please check the above errors, resolve them and try again.
Exit code was 1
@hohwille hohwille added the bug Something isn't working label Oct 21, 2022
@hohwille
Copy link
Member Author

Quite related error:

*** Setting up npm ***
doInstall nodejs  silent  /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node
Cloning or updating download mirrors
Already up to date.
Resolved latest version of nodejs to v19.0.0 from /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/mirrors/nodejs/available-versions
Starting installation of nodejs in version v19.0.0 to /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node
doDownload  /Users/hohwille/Downloads/devonfw-ide nodejs v19.0.0
Cloning or updating download mirrors
Already up to date.
Remapped architecture from x86_64 to x64 for software nodejs in version v19.0.0
Mapped extension to tar.gz for OS mac and software nodejs in version v19.0.0
Remapped OS from mac to darwin for software nodejs in version v19.0.0
Reading mirror URLs from /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/mirrors/nodejs/urls
Trying to download nodejs-v19.0.0-mac.tar.gz from https://nodejs.org/dist/v19.0.0/node-v19.0.0-darwin-x64.tar.gz
Artifact already exists at /Users/hohwille/Downloads/devonfw-ide/nodejs-v19.0.0-mac.tar.gz
To force update please delete the file and run again.
Received download file nodejs-v19.0.0-mac.tar.gz
Trying to run command tar xf '/Users/hohwille/Downloads/devonfw-ide/nodejs-v19.0.0-mac.tar.gz' -C '/Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/updates/extracted/node'
Success: run command tar
Successfully extracted archive nodejs-v19.0.0-mac.tar.gz to /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/updates/extracted/node
Changing source directory from /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/updates/extracted/node to /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/updates/extracted/node/node-v19.0.0-darwin-x64 due to single folder.
Trying to run command mv '/Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/updates/extracted/node/node-v19.0.0-darwin-x64' '/Users/hohwille/projects/software/default/nodejs/v19.0.0'
Success: run command mv
Successfully installed nodejs
The software node has been added. You need to rerun 'devon' command without arguments or restart your terminal to update your PATH so the newly installed software will be found.
Linking /Users/hohwille/projects/software/default/nodejs/v19.0.0 to /Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/software/node
Trying to verify installation of nodejs (node -v)
/Users/hohwille/projects/devon/workspaces/main/ide/scripts/target/integration-test/test-setup/scripts/command/../functions: line 85: node: command not found

******** ATTENTION ********
Failed to verify installation of nodejs (node)
We are sorry for the inconvenience. Please check the above errors, resolve them and try again.
Exit code was 127
Command 'node setup silent' failed with exit code 127

@hohwille
Copy link
Member Author

Error seemss to be presennt also without PR #934
The problem starts here:

local software_dir="${NODE_HOME}/node_modules/npm"

and next line is:
doInstall "-" "${software_dir}" "npm" "${software_version}"

So if DEVON_SOFTWARE_PATH is configured, doInstall will install npm into DEVON_SOFTWARE_PATH instead and then tries to create a symbolic link to make that central installation visible in the current devonfw-ide installation.
As it seems that is usually some folder inside the software folder that is assumed to exist.
Here we have some problems:

  1. IMHO we get an error because the symlink cannot be created as software/node/node_modules/npm since software/node/node_modules does not (yet) exist. So as a simple fix, we could first do mkdir -p on basedir before creating the symlink.
  2. A general problem is that some tools do not follow the philosophy we expect in devonfw-ide that each tool itself should be pristine and have no side effects on other tools. Fode node based stuff this is not the case: When I install node version XYZ and then I install npm version ABC, then this npm version ABC is installed into node XYZ. By default this is fine as you only mess your own local devonfw-ide installation. However, when using DEVON_SOFTWARE_PATH the problem is that one devonfw-ide installation has side effects on the other if they both want different versions of npm for the same node version it will cause problems. I was already aware of this problem due to plugin installations so I documented a warning for this feature (see caution): https://github.com/devonfw/ide/blob/master/documentation/software.asciidoc#shared

@hohwille
Copy link
Member Author

We should clarify why npm gets installed into node.
Maybe it can also "live" beside in its own folder what would solve the problem 1. easily.
However, I assume that something in node tooling might prevent this...

@hohwille
Copy link
Member Author

My gut feeling was correct:

npm -v
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module '/Users/hohwille/projects/software/default/nodejs/v19.0.0/bin/node_modules/npm/bin/npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v19.0.0
Could not determine Node.js install directory

A trick might be a special handling here and if DEVON_SOFTWARE_PATH is defined, we would create relative symlinks to ../../npm inside node/node_modules/ folder.
However, this does not work (at least on MacOS) as nowadays symlinks are proceessed much more accurate so that even if you are logically in a path containing symlinks a relative path is interpolated relative to is physical location.

@hohwille
Copy link
Member Author

So the only chance I see left here to fix this is to detect if DEVON_SOFTWARE_PATH is defined but our intallation path is already pointing inside a symlinked installation then we should behave as if DEVON_SOFTWARE_PATH was not defined for the current installation.

hohwille added a commit to hohwille/ide that referenced this issue Oct 21, 2022
hohwille added a commit to hohwille/ide that referenced this issue Oct 21, 2022
@hohwille hohwille added this to the release:2022.08.004 milestone Oct 21, 2022
hohwille added a commit that referenced this issue Nov 7, 2022
… doInstall (#934)

* #878: insteall latest version if unspecified

* #933: fixed typo

* #878: insteall latest version if unspecified also for docker

* #878: added to CHANGELOG

* #826: excuse rule for cobigen added

* #878: fixed stupid bug

* #847: fix for global tools and cobigen

* #878: #933: fixes and improvements

* #893: ability to configure version prefix

* #940: handle silent mode in doInstall and simplify doSetup

* #934: shellcheck fix

* #934: CHANGELOG

* #940: generalize macos workarounds

* #940: generalize macos workarounds

* #940: generalize macos workarounds

* #940: need to implement on mac, small improvements for debugging

* #940: generalize macos workarounds

* #940: generalize macos workarounds

* #940: fix - thanks shellcheck

* #940: fixed doInstall java extra arg order

* #940: OMG: fixed custom tools bug

* #893: extended test and fixed doVersionCompare

* #934: removed code entirely

* #934: removed TODO

* #934: simplified

* #934: fixed download caching

* #934: fixed aws

* #934: keep code to remove aws installer

* #934: fixed typos

* #957: symlink fix

* #957: symlink fix

* #934: fixed gcviewer

* #934: shellcheck fix

* #934: shellcheck war starts

* #934: improve DEVON_SOFTWARE_PATH on win

* #934: shellcheck fix

* #958: make symlinks work on windows

* #958: updated documentation

* #934: improved DoD from review comment

* #934: define HOME always on top

* #960: prevent "oc version" error

* #940: improve MacOS workaround

* #934: fixed doMavenArchetype

* #934: fixed aws

* #934: aligned and simplified

* #940: fixes for MacOS workaround

* #940: MacOS quickfix for eclipse

* #911: further improvements for eclipse

* #934: shellcheck fix

* #934: nasty shellcheck

* #960: added to CHANGELOG

* #961: split functions, fixed intellij version command on mac

* #961: fixed function doc

* Fix Add-plugin and custom start parameter

I fixxed the add plugin function which forgot to call vscode with "--install-extension".
And I changed the run command so it passes the arguments given to the run method, so you can run vscode with custom start parameters aswell now.

For example:
devon vscode run --list-extension

* #934: removed debug output

* #961: fixed function doc

* #934: #943: improve vscode plugin installation

* rename pip-latest-windows to pip-latest-pip

There was in an error installing pip on Windows because the installation file was renamed from pip-latest-windows-py to pip-latest-pip.py

* use cg --version

* #934: added missing X flags

* #940: fixed MacOS Workaround

* #934: python fix due to doInstall installer missuse

* #934: improved doc for shared software

* #934: rancher fix due to doInstall installer missuse

* #934: kubectl shall not have knowledge about docker installation

Co-authored-by: Genetics <102921542+Amueller36@users.noreply.github.com>
Co-authored-by: alfeilex <101652401+alfeilex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant