emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
3.03k stars 693 forks source link

emsdk_env.bat doesn't set all the environment variables #167

Closed fibbo closed 4 years ago

fibbo commented 6 years ago

I've only had this problem since upgrading to 1.38.11 (before I used 1.38.6). I also tried a complete reinstallation of emscripten.

What I do:

Now when I run this command only following variables will be set:

Adding directories to PATH:
PATH += c:\emsdk-portable

Setting environment variables:
EMSDK = c:/emsdk-portable
EM_CONFIG = C:\Users\pgl\.emscripten

And this is not sufficient for emscripten to work. What am I missing, what changed?

Using Windows 10, non elevated command-prompt

Edit: Seems to have to do with following commit: https://github.com/juj/emsdk/commit/23dba8d27ba5f5659e0315ddf7b986781dad469f#diff-fadf99b8a6bd0f70987e30f153eb9b44

OK the problems seems to be the comparison of strings where the cases don't match. With EMSDK_VERBOSE

clang-e1.38.11-64bit is not active, because key="LLVM_ROOT" has value "'c:/emsdk-portable/clang/e1.38.11_64bit'" but should have value "'C:/emsdk-portable/clang/e1.38.11_64bit'"
node-8.9.1-64bit is not active, because key="NODE_JS" has value "'c:/emsdk-portable/node/8.9.1_64bit/bin/node.exe'" but should have value "'C:/emsdk-portable/node/8.9.1_64bit/bin/node.exe'"
python-2.7.13.1-64bit is not active, because key="PYTHON" has value "'c:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'" but should have value "'C:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'"
java-8.152-64bit is not active, because key="JAVA" has value "'c:/emsdk-portable/java/8.152_64bit/bin/java.exe'" but should have value "'C:/emsdk-portable/java/8.152_64bit/bin/java.exe'"
emscripten-1.38.11 is not active, because key="EMSCRIPTEN_ROOT" has value "'c:/emsdk-portable/emscripten/1.38.11'" but should have value "'C:/emsdk-portable/emscripten/1.38.11'"
python-2.7.13.1-64bit is not active, because key="PYTHON" has value "'c:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'" but should have value "'C:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'"
python-2.7.13.1-64bit is not active, because key="PYTHON" has value "'c:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'" but should have value "'C:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'"
python-2.7.13.1-64bit is not active, because key="PYTHON" has value "'c:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'" but should have value "'C:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'"
python-2.7.13.1-64bit is not active, because key="PYTHON" has value "'c:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'" but should have value "'C:/emsdk-portable/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'"
Adding directories to PATH:
PATH += C:\emsdk-portable

Setting environment variables:
EMSDK = C:/emsdk-portable
kripken commented 6 years ago

cc @juj, the commit causing the regression is one of yours, see above.

juj commented 6 years ago

Sorry, tried to get this to reproduce, but I am not quite able to find the exact conditions. The presence of c:/ in lower case looks odd, but I'm not sure how to get that. I am trying to repro with

git clone https://github.com/juj/emsdk.git
cd emsdk
emsdk install latest
emsdk activate latest

and then close command prompt, and open a new one, with

cd emsdk
emsdk_env

which does correctly yield

C:\code\emsdk>emsdk_env
Adding directories to PATH:
PATH += C:\code\emsdk
PATH += C:\code\emsdk\clang\e1.38.11_64bit
PATH += C:\code\emsdk\node\8.9.1_64bit\bin
PATH += C:\code\emsdk\python\2.7.13.1_64bit\python-2.7.13.amd64
PATH += C:\code\emsdk\java\8.152_64bit\bin
PATH += C:\code\emsdk\emscripten\1.38.11
PATH += C:\code\emsdk\mingw\7.1.0_64bit\bin

Setting environment variables:
EMSDK = C:/code/emsdk
EM_CONFIG = C:\Users\jukkaj\.emscripten
LLVM_ROOT = C:\code\emsdk\clang\e1.38.11_64bit
EMSCRIPTEN_NATIVE_OPTIMIZER = C:\code\emsdk\clang\e1.38.11_64bit\optimizer.exe
BINARYEN_ROOT = C:\code\emsdk\clang\e1.38.11_64bit\binaryen
EMSDK_NODE = C:\code\emsdk\node\8.9.1_64bit\bin\node.exe
EMSDK_PYTHON = C:\code\emsdk\python\2.7.13.1_64bit\python-2.7.13.amd64\python.exe
JAVA_HOME = C:\code\emsdk\java\8.152_64bit
EMSCRIPTEN = C:\code\emsdk\emscripten\1.38.11

Note that on Windows if you run emsdk_env in the same prompt where you call emsdk activate, then emsdk_env does nothing, since emsdk activate already does emsdk_env step (on Linux and macOS it does not, because of the additional requirement to have to source scripts)

For example:

C:\code\emsdk>emsdk activate latest
Writing .emscripten configuration file to user home directory C:\Users\jukkaj/
The Emscripten configuration file C:\Users\jukkaj\.emscripten has been rewritten with the following contents:

import os
MINGW_ROOT='C:/code/emsdk/mingw/7.1.0_64bit'
LLVM_ROOT='C:/code/emsdk/clang/e1.38.11_64bit'
EMSCRIPTEN_NATIVE_OPTIMIZER='C:/code/emsdk/clang/e1.38.11_64bit/optimizer.exe'
BINARYEN_ROOT='C:/code/emsdk/clang/e1.38.11_64bit/binaryen'
NODE_JS='C:/code/emsdk/node/8.9.1_64bit/bin/node.exe'
PYTHON='C:/code/emsdk/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'
JAVA='C:/code/emsdk/java/8.152_64bit/bin/java.exe'
EMSCRIPTEN_ROOT='C:/code/emsdk/emscripten/1.38.11'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = 'c:/users/jukkaj/appdata/local/temp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

Adding directories to PATH:
PATH += C:\code\emsdk
PATH += C:\code\emsdk\mingw\7.1.0_64bit\bin
PATH += C:\code\emsdk\clang\e1.38.11_64bit
PATH += C:\code\emsdk\node\8.9.1_64bit\bin
PATH += C:\code\emsdk\python\2.7.13.1_64bit\python-2.7.13.amd64
PATH += C:\code\emsdk\java\8.152_64bit\bin
PATH += C:\code\emsdk\emscripten\1.38.11

Setting environment variables:
EMSDK = C:/code/emsdk
EM_CONFIG = C:\Users\jukkaj\.emscripten
LLVM_ROOT = C:\code\emsdk\clang\e1.38.11_64bit
EMSCRIPTEN_NATIVE_OPTIMIZER = C:\code\emsdk\clang\e1.38.11_64bit\optimizer.exe
BINARYEN_ROOT = C:\code\emsdk\clang\e1.38.11_64bit\binaryen
EMSDK_NODE = C:\code\emsdk\node\8.9.1_64bit\bin\node.exe
EMSDK_PYTHON = C:\code\emsdk\python\2.7.13.1_64bit\python-2.7.13.amd64\python.exe
JAVA_HOME = C:\code\emsdk\java\8.152_64bit
EMSCRIPTEN = C:\code\emsdk\emscripten\1.38.11

Set the following tools as active:
   mingw-7.1.0-64bit
   clang-e1.38.11-64bit
   node-8.9.1-64bit
   python-2.7.13.1-64bit
   java-8.152-64bit
   emscripten-1.38.11

The changes made to environment variables only apply to the currently running shell instance. Use the 'emsdk_env.bat' to re-enter this environment later, or if you'd like to permanently register this environment globally to all users in Windows Registry, rerun this command with the option --global.

C:\code\emsdk>emsdk_env
Adding directories to PATH:
PATH += C:\code\emsdk
PATH += C:\code\emsdk\clang\e1.38.11_64bit
PATH += C:\code\emsdk\node\8.9.1_64bit\bin
PATH += C:\code\emsdk\python\2.7.13.1_64bit\python-2.7.13.amd64
PATH += C:\code\emsdk\java\8.152_64bit\bin
PATH += C:\code\emsdk\emscripten\1.38.11
PATH += C:\code\emsdk\mingw\7.1.0_64bit\bin

Setting environment variables:
EMSDK = C:/code/emsdk

C:\code\emsdk>where emcc
C:\code\emsdk\emscripten\1.38.11\emcc
C:\code\emsdk\emscripten\1.38.11\emcc.bat
C:\code\emsdk\emscripten\1.38.11\emcc.py

(The second print of Adding directories to PATH: there is a bit redundant, it's re-adding ones already present, just in different order)

Does the issue still occur? Can you post the exact command line you are trying with?

Slluxx commented 6 years ago

@juj i tried it with your exact steps you mentioned above. its also not working for me. i mean it says that its setting up the variables but i cant use emcc in any other folder (exept if i set it up temporarily and then switch folders.)

no difference if i start the second cmd as administrator or not

AlexanderPattison commented 4 years ago

I am also having this issue to set the environment variable in Ubuntu 18.04. I followed these steps:

curl -L https://github.com/emscripten-core/emsdk/archive/1.39.19.zip > emsdk.zip
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
python ./emsdk.py install latest
python ./emsdk.py activate latest
source ./emsdk_env.sh

When I do printenv EMSDK, nothing is returned.

sbc100 commented 4 years ago

What does source ./emsdk_env.sh output, if anything?

What shell are you using?

What does emsdk construct_env (the underlying tool) print?

AlexanderPattison commented 4 years ago

Output when called in a new bash session.

ubuntu@ubuntu:~/emsdk$ source ./emsdk_env.sh
Adding directories to PATH:
PATH += /home/ubuntu/emsdk
PATH += /home/ubuntu/emsdk/upstream/emscripten
PATH += /home/ubuntu/emsdk/node/12.18.1_64bit/bin

Setting environment variables:
EMSDK = /home/ubuntu/emsdk
EM_CONFIG = /home/ubuntu/emsdk/.emscripten
EM_CACHE = /home/ubuntu/emsdk/upstream/emscripten/cache
EMSDK_NODE = /home/ubuntu/emsdk/node/12.18.1_64bit/bin/node

Nothing is outputted if I call again in same session. If I start a new bash session, this is still the output.

I am using bash:

ubuntu@ubuntu:~/emsdk$ echo "$SHELL"
/bin/bash

When in a new bash session: source ./emsdk_env.sh (get above return) then emsdk construct_env return is nothing.

When in a new bash session: emsdk construct_env return is: emsdk: command not found

sbc100 commented 4 years ago

What version of emsdk are you using? It looks like maybe you are using an old version?

AlexanderPattison commented 4 years ago

Ah I think you right... Instead, I cloned the repository and did:

python ./emsdk.py install latest
python ./emsdk.py activate latest
source ./emsdk_env.sh

Now printenv shows it works for me

ubuntu@ubuntu:~/Github/emsdk$ printenv EMSDK
/home/ubuntu/Github/emsdk

Now when I use it with what I'm doing, I do export EMSDK=/home/ubuntu/Github/emsdk . Works for me! Thanks.