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

Inconsistent availability of node and npm binaries after sourcing emsdk_env.sh multiple times #1240

Closed
shakhvit opened this issue Jun 23, 2023 · 3 comments · Fixed by #1250
Closed

Comments

@shakhvit
Copy link

Description:

When I source the environment setup file emsdk_env.sh for emsdk (commit c2260b4 -- current main), node and npm binaries are correctly added to my path the first time. However, when I source emsdk_env.sh again, node and npm are no longer accessible. Sourcing a third time brings them back, and this pattern continues with each subsequent sourcing.

Steps to reproduce:

  1. Clone the most recent version of emsdk (commit c2260b4).
  2. Run the commands:
./emsdk install 3.1.3
./emsdk activate 3.1.3
  1. Source the environment with source ./emsdk_env.sh.
  2. Check that node and npm are available by running node -v and npm -v.
  3. Source the environment again with source ./emsdk_env.sh.
  4. Check node and npm availability again. They are not found.
  5. Source the environment again and check node and npm. They are available again.
  6. Continue this cycle of sourcing and checking. You will see that the availability of node and npm alternates with each sourcing.

Environment:

  • OS: Linux
  • Shell: bash
  • Emscripten SDK version: c2260b4

I hope this issue can be addressed. Thank you for your time and help.

@sbc100
Copy link
Collaborator

sbc100 commented Jun 23, 2023

Thanks for the report.. I actually noticed this issue the other day myself.

Its actually good to know that you noticed this... since I wasn't sure if folks out there were using out embedded version of node outside of the emcc tool. Can I ask what you are using it for?

BTW, one temporary solution is to use the $EMSDK_NODE environment variable which we set to point to this copy of node.

@shakhvit
Copy link
Author

@sbc100, thank you for your response. I've already developed a temporary workaround for this issue. The solution involves creating a wrapper script that guarantees emsdk_env.sh is only sourced a single time.

Our project requires both emcc (for compiling C++ code into WASM) and Node.js (for operating certain backend network components). Given that emcc's toolkit already includes Node.js, it makes sense for us to utilize this bundled Node.js. It saves us from having to manage a separate Node.js installation. :)

@sbc100
Copy link
Collaborator

sbc100 commented Jun 26, 2023

I see. Interesting to know that some folks are taking advantage of our bundled version of node. My understanding was that most folks using node in production would actually want something a lot more recent (and more under their own control), but I stand corrected.

Another temporary option would be to install your own separate version of node. Even with the current bug emsdk_env should never remove that version from you PATH.

sbc100 added a commit that referenced this issue Jun 27, 2023
The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: #1240
sbc100 added a commit that referenced this issue Jun 27, 2023
The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: #1240
sbc100 added a commit that referenced this issue Jun 27, 2023
The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: #1240
sbc100 added a commit that referenced this issue Jun 27, 2023
The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: #1240
sbc100 added a commit that referenced this issue Jun 27, 2023
The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: #1240
shlomif pushed a commit to shlomif/emsdk that referenced this issue Sep 29, 2023
…ripten-core#1250)

The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: emscripten-core#1240
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

Successfully merging a pull request may close this issue.

2 participants