emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
3.01k stars 687 forks source link

Environment vars are not set on WIndows 10 #1121

Open sasmaster opened 2 years ago

sasmaster commented 2 years ago

I ran the emsdk setup on two different machines with Win 10 and running emsdk_env.bat via any kind of termina (git bash, native tools cmd ) including in admin mode doesn't set the env vars.

sbc100 commented 2 years ago

Can you show the command you ran and along with its full output?

After you run emsdk_env.bat can you run which emcc?

sasmaster commented 2 years ago

Well, I have already added all the env vars manually to PATH, but Yes ran emsdk_env.bat

which emcc : /c/Users/xxx/Documents/emsdk/upstream/emscripten/emcc

Running emsdk_env.bat give this:

`Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1) Adding directories to PATH: PATH += C:\Users\explo\Documents\emsdk

Setting environment variables: PATH = C:\Users\explo\Documents\emsdk;C:\Users\explo\Documents\emsdk\upstream\emscripten;C:\Users\explo\Documents\emsdk\node\14.18.2_64bit\bin; .... //the rest of the path vars which are not related to emsdk goes here.... JAVA_HOME = C:\Users\explo\Documents\emsdk\java\8.152_64bit Clearing existing environment variable: EMSDK_PY`

As I said, it happens on two different machines. CMD is run in admin mode. I am currently able to use the SDK and compile my project, but I had to add those vars manually.

sbc100 commented 2 years ago

So emsdk_env.bat won't add paths that are already present in your PATH.

Can you verify that variables are being set correctly but running echo %JAVA_HOME and echo %PATH after running emsdk_env.bat. If you see C:\Users\explo\Documents\emsdk at the start of your PATH, which I imagine you will then things are working as expected.

Perhaps you are expecting the variables in your registry to be updated by emsdk_env, where as by default it only effects the current shell? i.e. the idea is that you run it in each shell that you open. Alternatively you can activate with --permanent to have the registry updated (see emsdk activate --help).

sasmaster commented 2 years ago

No no, you didn't get me. It doesn't set paths even if that's a clean start.

On Mon, Oct 10, 2022, 17:17 Sam Clegg @.***> wrote:

So emsdk_env.bat won't add paths that are already present in your PATH.

Can you verify that variables are being set correctly but running echo %JAVA_HOME and echo %PATH after running emsdk_env.bat. If you see C:\Users\explo\Documents\emsdk at the start of your PATH, which I imagine you will then things are working as expected.

Perhaps you are expecting the variables in your registry to be updated by emsdk_env, where as by default it only effects the current shell? i.e. the idea is that you run it in each shell that you open. Alternatively you can activate with --permanent to have the registry updated (see emsdk activate --help).

— Reply to this email directly, view it on GitHub https://github.com/emscripten-core/emsdk/issues/1121#issuecomment-1273387405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADLBADFR7LGCGJDT4V7LT3WCQQRNANCNFSM6AAAAAAQ7PF3DQ . You are receiving this because you authored the thread.Message ID: @.***>

sbc100 commented 2 years ago

So if you have a shell that doesn't have emcc in the PATH, when emsdk_env.bar it doesn't add this path? That seems very odd.

Can you make sure by running in new shell which doesn't have emcc in PATH at all (make sure that which emcc fails) and then run emsdk_env.bat and attach the full output?

kalwalt commented 1 year ago

@sbc100 @sasmaster i have the same issue with Windows 11, i need to run every time the emsdk_env.bat to apply the env path. Furthermore i have issue with emcmake, but i don't know if this is related. I checked in the env variable manager and esmcripten PATHare applied only for the user not globally, and it miss EMSDK and other variables (EMSDK_NODE, EMSDK_PYTHON, JAVA_HOME). I solved manually adding them in the env variable manager.

sbc100 commented 1 year ago

If you want to avoid having to run emsdk_env in every shell you can add --permanent to the activate command. From the help message:

   emsdk activate [--permanent] [--system] [--build=type] [--vs2017/--vs2019] <tool/sdk>

                                - Activates the given tool or SDK in the           
                                  environment of the current shell.                

                                - If the `--permanent` option is passed, then the environment
                                  variables are set permanently for the current user.

                                - If the `--system` option is passed, the registration
                                  is done for all users of the system.             
                                  This needs admin privileges                      
                                  (uses Machine environment variables).            e.        
kalwalt commented 1 year ago

If you want to avoid having to run emsdk_env in every shell you can add --permanent to the activate command. From the help message:

   emsdk activate [--permanent] [--system] [--build=type] [--vs2017/--vs2019] <tool/sdk>

                                - Activates the given tool or SDK in the           
                                  environment of the current shell.                

                                - If the `--permanent` option is passed, then the environment
                                  variables are set permanently for the current user.

                                - If the `--system` option is passed, the registration
                                  is done for all users of the system.             
                                  This needs admin privileges                      
                                  (uses Machine environment variables).            e.        

Yes that did the trick thank you so much @sbc100 !