emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 662 forks source link

PermissionError after emcc test #1344

Closed Jillinger closed 5 months ago

Jillinger commented 5 months ago

Everything was working fine until I ran this test: emcc test/hello_world_file.cpp -o hello.html --preload-file test/hello_world_file.txt Now, I keep getting this error, on every emcc command I ran:

Traceback (most recent call last):
  File "C:\develop\emsdk\upstream\emscripten\emcc.py", line 37, in <module>
    from tools import shared, system_libs, utils, ports
  File "C:\develop\emsdk\upstream\emscripten\tools\shared.py", line 44, in <module>
    from . import cache, tempfiles
  File "C:\develop\emsdk\upstream\emscripten\tools\cache.py", line 14, in <module>
    from . import filelock, config, utils
  File "C:\develop\emsdk\upstream\emscripten\tools\config.py", line 311, in <module>
    init()
  File "C:\develop\emsdk\upstream\emscripten\tools\config.py", line 308, in init
    read_config()
  File "C:\develop\emsdk\upstream\emscripten\tools\config.py", line 159, in read_config
    parse_config_file()
  File "C:\develop\emsdk\upstream\emscripten\tools\config.py", line 116, in parse_config_file
    config_text = utils.read_file(EM_CONFIG)
  File "C:\develop\emsdk\upstream\emscripten\tools\utils.py", line 63, in read_file
    with open(file_path, encoding='utf-8') as fh:
PermissionError: [Errno 13] Permission denied: 'C:\\develop\\emsdk\\upstream\\emscripten'

What went wrong?

sbc100 commented 5 months ago

Did you run emsdk activate <version> to activate the sdk? And then did you run emsdk_env.bat to setup the paths?

For some reason emscripten is not finding he correct config file which should be C:\\develop\\emsdk\\.emscripten.

Can you try running set EMCC_DEBUG=1 before running the emcc command?

Jillinger commented 5 months ago

I didn't realize there should be a dot (.) before emscripten. That seems to have fixed the problem.

C:\WINDOWS\system32>emcc -v
config:DEBUG: emscripten config is located in C:\develop\emsdk\upstrea\.emscripten
tools.filelock:DEBUG: Attempting to acquire lock 663349823328 on C:\Users\pcGeek\A
ppData\Local\Temp\emscripten_temp\emscripten.lock
tools.filelock:DEBUG: Lock 663349823328 acquired on C:\Users\pcGeek\AppData\Local\
Temp\emscripten_temp\emscripten.lock
profiler:DEBUG: block "read_ports" took 0.061 seconds
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (c
e5114bdd2175c7297583d3c25a53ca95d22f4ce)
clang version 15.0.7
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
shared:DEBUG: executed "C:\Program Files\LLVM\bin\clang.exe" -v -target wasm32-unknown-emscripten
emcc:DEBUG: total time: 27.17 seconds
profiler:DEBUG: block "main" took 27.170 seconds
tools.filelock:DEBUG: Attempting to release lock 663349823328 on C:\Users\pcGeek\A
ppData\Local\Temp\emscripten_temp\emscripten.lock
tools.filelock:DEBUG: Lock 663349823328 released on C:\Users\pcGeek\AppData\Local\
Temp\emscripten_temp\emscripten.lock

C:\WINDOWS\system32>emcc --check
config:DEBUG: emscripten config is located in C:\develop\emsdk\upstream\.emscripten
tools.filelock:DEBUG: Attempting to acquire lock 964591946960 on C:\Users\pcGeek\AppData\Local\Temp\emscripten_temp\emscripten.lock
tools.filelock:DEBUG: Lock 964591946960 acquired on C:\Users\pcGeek\AppData\Local\
Temp\emscripten_temp\emscripten.lock
profiler:DEBUG: block "read_ports" took 0.031 seconds
emcc:WARNING: invocation: C:\develop\emsdk\upstream\emscripten\emcc.py --check (in C:\WINDOWS\system32)
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (ce5114bdd2175c7297583d3c25a53ca95d22f4ce)
cache:DEBUG: PID 9832 acquiring multiprocess file lock to Emscripten cache at C:\develop\emsdk\upstream\emscripten\cache
tools.filelock:DEBUG: Attempting to acquire lock 964593002144 on C:\develop\emsdk\upstream\emscripten\cache\cache.lock
tools.filelock:DEBUG: Lock 964593002144 acquired on C:\develop\emsdk\upstream\emscripten\cache\cache.lockcache:DEBUG: done
shared:INFO: old sanity: 3.1.53|C:/develop/emsdk/upstream/bin
shared:INFO: new sanity: 3.1.53|C:\Program Files\LLVM\bin
shared:INFO: (Emscripten: config changed, clearing cache)
shared:DEBUG: successfully executed "C:\Program Files\nodejs\node.EXE" --version

shared:DEBUG: successfully executed "C:\Program Files\LLVM\bin\clang.exe" --version
emcc: warning: LLVM version for clang executable "C:\Program Files\LLVM\bin\clang.exe" appears incorrect (seeing "15.0", expected "19") [-Wversion-check]
shared:DEBUG: successfully executed "C:\Program Files\LLVM\bin\clang.exe" -print-targets
shared:INFO: (Emscripten: Running sanity checks)
shared:DEBUG: successfully executed "C:\Program Files\nodejs\node.EXE" -e console.log("hello")
profiler:DEBUG: block "check_node" took 0.268 seconds
profiler:DEBUG: block "sanity LLVM" took 0.033 seconds
tools.filelock:DEBUG: Attempting to release lock 964593002144 on C:\develop\emsdk\upstream\emscripten\cache\cache.lock
tools.filelock:DEBUG: Lock 964593002144 released on C:\develop\emsdk\upstream\emscripten\cache\cache.lock
cache:DEBUG: PID 9832 released multiprocess file lock to Emscripten cache at C:\develop\emsdk\upstream\emscripten\cache
profiler:DEBUG: block "check_sanity" took 20.432 seconds
profiler:DEBUG: block "parse arguments" raised an exception after 20.434 seconds

profiler:DEBUG: block "main" raised an exception after 20.436 seconds
tools.filelock:DEBUG: Attempting to release lock 964591946960 on C:\Users\pcGeek\A
ppData\Local\Temp\emscripten_temp\emscripten.lock
tools.filelock:DEBUG: Lock 964591946960 released on C:\Users\pcGeek\AppData\Local\Temp\emscripten_temp\emscripten.lock

The debug flag is cool.

emcc: warning: LLVM version for clang executable "C:\Program Files\LLVM\bin\clang.exe" appears incorrect (seeing "15.0", expected "19") [-Wversion-check]

Unimportant side question. Why is 19 expected, when the latest is 17? Would 19 be pre-released? You may close the issue, when ready. Thanks a lot.

sbc100 commented 5 months ago

What method are you using the tell emcc where to find the config file? Are you setting EM_CONFIG youself? You should not need to do that.. emsdk_env.bat should do all that for you.

Jillinger commented 5 months ago

Yes, I know, but I prefer to manually set paths in my EV, when there are multiple paths to set, for organizational purposes, and to make sure the path length is within limits. I'v had issues with some of the paths being chopped. So, I prefer to do the chopping, if need be. I know. The dot (.) got me this time, and it could happen again, but that's why I like github. You guys are really on the ball... unlike some community forums, I know. No names. Thanks again.

sbc100 commented 5 months ago

If you want to set your own paths then just run emsdk_env.bat and look what it outputs. It should show something like this:

Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1)
Adding directories to PATH:
PATH += /home/sbc/dev/wasm/emsdk
PATH += /home/sbc/dev/wasm/emsdk/upstream/emscripten

Setting environment variables:
PATH = /home/sbc/dev/wasm/emsdk:/home/sbc/dev/wasm/emsdk/upstream/emscripten:/home/sbc/bin/node-v16.20.0-linux-x64//bin:/home/sbc/bin/google_appengine:/home/sbc/.local/bin:/home/sbc/bin:/home/sbc/bin/depot_tools:/home/sbc/.cargo/bin:/usr/lib/google-golang/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/sbc/bin/arm:/opt/local/bin:/opt/local/sbin:/home/sbc/bin/gsutil:/home/sbc/bin/phabricator/arcanist/bin
EMSDK = /home/sbc/dev/wasm/emsdk
EMSDK_NODE = /home/sbc/dev/wasm/emsdk/node/16.20.0_64bit/bin/node

(yours will looks different because you are on windows).

If you want emsdk to work correctly you will need to mimic all of those change to your environment somehow.

Jillinger commented 5 months ago

I got everything setup fine. I had used this. I just missed the dot (.). I had actually ran emcc with no problems. I saved a log.

C:\develop\emsdk>where emcc
C:\develop\emsdk\upstream\emscripten\emcc
C:\develop\emsdk\upstream\emscripten\emcc.bat

C:\develop\emsdk>emcc --version
shared:INFO: (Emscripten: Running sanity checks)
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (ce5114bdd2175c7297583d3c25a53ca95d22f4ce)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

C:\develop\emsdk>emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (c
e5114bdd2175c7297583d3c25a53ca95d22f4ce)
clang version 19.0.0git (https://github.com/llvm/llvm-projectfebb4c42b192ed7c88c17f91cb903a59acf20baf)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\develop\emsdk\upstream\bin

C:\develop\emsdk>emcmdprompt.bat
Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1)
Setting environment variables:
Clearing existing environment variable: EMSDK_PY

C:\develop\emsdk>emcc --check
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (ce5114bdd2175c7297583d3c25a53ca95d22f4ce)
shared:INFO: (Emscripten: Running sanity checks)

C:\develop\emsdk>gcc --version
gcc (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

C:\develop\emsdk>emcc --show-ports
Available ports:
    Boost headers v1.70.0 (USE_BOOST_HEADERS=1; Boost license)
    bullet (USE_BULLET=1; zlib license)
    bzip2 (USE_BZIP2=1; BSD license)
    cocos2d
    freetype (USE_FREETYPE=1; freetype license)
    giflib (USE_GIFLIB=1; MIT license)
    harfbuzz (USE_HARFBUZZ=1; MIT license)
    icu (USE_ICU=1; Unicode License)
    libjpeg (USE_LIBJPEG=1; BSD license)
    libmodplug (USE_MODPLUG=1; public domain)
    libpng (-sUSE_LIBPNG; zlib license)
    mpg123 (USE_MPG123=1; zlib license)
    ogg (USE_OGG=1; zlib license)
    regal (USE_REGAL=1; Regal license)
    SDL2 (USE_SDL=2; zlib license)
    SDL2_gfx (zlib license)
    SDL2_image (USE_SDL_IMAGE=2; zlib license)
    SDL2_mixer (USE_SDL_MIXER=2; zlib license)
    SDL2_net (zlib license)
    SDL2_ttf (-sUSE_SDL_TTF=2; zlib license)
    sqlite (USE_SQLITE3=1); public domain)
    vorbis (-sUSE_VORBIS; zlib license)
    zlib (USE_ZLIB=1; zlib license)

C:\develop\emsdk>emcc C:\develop\hello_world.c
cache:INFO: generating system asset: symbol_lists/b1233c7e244324ac18ced47dc5f862
e44f7f18c4.json... (this will be cached in "C:\develop\emsdk\upstream\emscripten\cache\symbol_lists\b1233c7e244324ac18ced47dc5f862e44f7f18c4.json"for subsequent builds)
cache:INFO:  - ok

C:\develop\emsdk>node C:\develop\emsdk\a.out.js
hello, world!

C:\develop\emsdk>emcc C:\develop\hello_world.c -o hello.html

Until I used the test from here. emcc test/hello_world_file.cpp -o hello.html --preload-file test/hello_world_file.txt Then everything went haywire.

I think my system is acting weird, because I set emsdk mingw32 on the path, and was able to run the command mingw-get -h, and get results. I restarted my computer, and ran the same command, and got the message that _mingw-get isn't recognized. Yet, it's set in the path.

It's a pc thing, I guess.