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

Maven build use node from PATH on mac os #1247

Closed
zulus opened this issue Jun 13, 2023 · 9 comments
Closed

Maven build use node from PATH on mac os #1247

zulus opened this issue Jun 13, 2023 · 9 comments
Labels

Comments

@zulus
Copy link
Contributor

zulus commented Jun 13, 2023

For now this code always return true on MAC: https://github.com/eclipse/wildwebdeveloper/blob/e52e0990f609f3dcbac5648a4bd012ecf9d753a5

Due this process builder always receiving NPM absolute path only, so use node from PATH (if exists) or fail (/bin/env node)

I think line from above should be just dropped, npm should always be prefixed by built-in node (if exists)

@vrubezhny
Copy link
Contributor

@zulus Thanks for pointing to the issue. I have no Mac to test, but I'll try setting up a GitHub action to run the tests.
Contributions are also welcomed.

@vrubezhny
Copy link
Contributor

Well, I tried to create a Github Workflow to build and test WWD using MacOS:

Operating System
  macOS
  12.6.5
  21G531

... and having it configured to be pre-installed with Node.js v.20.x:

Environment details
  node: v20.3.0
  npm: 9.6.7
  yarn: 1.22.19

...I see the following npm commands logged:

Running org.eclipse.wildwebdeveloper.tests.TestESLint
2023-06-15T21:04:15.8346370Z [/Users/runner/work/wildwebdeveloper/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/target/work/.node/node-v18.16.0-darwin-x64/bin/npm, install, --no-bin-links, --ignore-scripts]

... which clearly shows that the embedded installation of Node.js (v18.16.0) is used to run an npm install command on that MacOS, and not the system one (v20.3.0).

@zulus Are you sure your eclipse.ini or a Launch configuration is not added with -Dorg.eclipse.wildwebdeveloper.nodeJSLocation=... option pointing to a different Mode.js installation?

Unfortunately, I have no Mac to try debugging it locally.

@zulus
Copy link
Contributor Author

zulus commented Jun 16, 2023

Running org.eclipse.wildwebdeveloper.tests.TestESLint
2023-06-15T21:04:15.8346370Z [/Users/runner/work/wildwebdeveloper/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/target/work/.node/node-v18.16.0-darwin-x64/bin/npm, install, --no-bin-links, --ignore-scripts]

... which clearly shows that the embedded installation of Node.js (v18.16.0) is used to run an npm install command on that MacOS, and not the system one (v20.3.0).

No, it means it use Eclipse built-in NPM. NPM script have on header #!/bin/env node, so system use node from PATH. Check what PATH you have before execution. Eventually try run which node.

On Windows you will see node_cmd npm_cms args

@zulus
Copy link
Contributor Author

zulus commented Jun 16, 2023

I'm afraid same problem might be on linux, I'll later confirm. Tests rather than use built-in one, use node from github actions.

@vrubezhny vrubezhny added the bug label Jun 17, 2023
@vrubezhny
Copy link
Contributor

@zulus Yes, I think you're right - this is a real issue. Thanks for reporting it!

@zulus
Copy link
Contributor Author

zulus commented Jun 29, 2023

I'm afraid same problem might be on linux, I'll later confirm. Tests rather than use built-in one, use node from github actions.

Same on linux. Problem is with npm calls in general on *nix systems. Eclipse rely on PATH for all NPM cals, and completely ignore built-in node. Checked on fresh fedora 36 ARM64 (virtual machine), run as npm inside project.

Result in console:

/usr/bin/env: ‘node’: No such file or directory

BTW would be nice if WWD could add to ENV[PATH] built-in node bin so TM Terminal could have an access ;) I can create separate task

@vrubezhny
Copy link
Contributor

@zulus Yes. I can confirm.

The only way I see to fix it is to modify those scripts replacing the node with <full-path-to-node>/node in every embedded script after the installation.

We can't change the PATH environment variable pointing to the embedded binaries first to help the env utility to find the embedded versions first because we're not providing a way to start node, npm, etc - we're only providing paths to the executables, while changing the PATH globally at some point will create more inconsistencies for the users (for example, when WWD is uninstalled/moved to another path, etc.)

@zulus
Copy link
Contributor Author

zulus commented Jun 29, 2023

So npm runs should works in same way as we launch all language servers:

NODE_PATH LANGUAGE_SERVER_JS params

For now, on windows special CMD is created on the fly (magic withProgram), if node not exists in PATH. And only for npm and only for windows, so to be honest, you haven't real npm path on windows

@vrubezhny
Copy link
Contributor

On windows we can probably update the npm.cmd and npx.cmd are used, so we can add something like

set "PATH=<Emdebed-Node.js-path>\bin;%PATH%" to the beginning those scripts.

Or even just change

SET "NODE_EXE=%~dp0\node.exe"

with something like

SET "NODE_EXE=<Emdebed-Node.js-path>\bin\node.exe"

(not sure what is the meaning of %~dp0, but it looks like a predefined env. variable...

Not sure if this would work, though.

zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 24, 2023
zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 24, 2023
zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 24, 2023
zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 24, 2023
zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 24, 2023
zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 25, 2023
zulus added a commit to zulus/wildwebdeveloper that referenced this issue Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants