Skip to content

Incorrect path resolution in emcc.bat/em++.bat #19207

Closed

Description

@arpit18

Please include the following in your bug report:

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.33 (c1927f2)
clang version 17.0.0 (https://github.com/llvm/llvm-project 671eeece457f6a5da7489f7b48f7afae55327b8b)
Target: wasm32-unknown-emscripten
Thread model: posix

Description

Possible Solution

  • Since the path to emsdk is available in the EMSDK environment variable, it can be used to replace "%~dp0\%~n0.py" with "%EMSDK%\upstream\emscripten\%~n0.py

Activity

  1. juj commented on Apr 19, 2023

    @juj
    Collaborator

    When invoked with quotes ("emcc"), the resolution of "%~dp0%~n0.py" in emcc.bat causes issues

    Trying to reproduce, with

    t.bat

    @setlocal
    
    @set EM_PY=%EMSDK_PYTHON%
    @if "%EM_PY%"=="" (
      set EM_PY=python
    )
    
    @if "%_EMCC_CCACHE%"=="" (
      set CMD="%EM_PY%" -E "%~dp0\%~n0.py"
    )
    
    @echo %CMD% %*

    but at least on my Windows 10, I am unable to coax out a difference:

    image

    I also tried to follow the repro at https://stackoverflow.com/a/26851883 , but was not able to reproduce the issue. The post is 10 years old, so possibly the issue has been since fixed in Windows.

    Would you have isolated repro steps that reproduces the issue for you? Which Windows OS version are you on?

  2. arpit18 commented on Apr 20, 2023

    @arpit18
    Author

    The isolated repro steps are as follows (also available @ https://github.com/arpit18/emscripten-issue-19207) :

    1. Create a project folder
    2. Add a Hello.cpp file that prints the "Hello World" message
    3. Create and run a build.bat batch file that runs the command emcc Hello.cpp
    4. Create and run a build_with_quotes.bat batch file that runs the command "emcc" Hello.cpp (with quotes around the emcc command)

    Observations

    • The build succeeds in Step 2
    • Step 3 fails with the following message: <path-to-emsdk>\python\3.9.2-nuget_64bit\python.exe can't open file '<path-to-build_with_quotes.bat>\emcc.py': [Errno 2] No such file or directory

    OS Details
    Windows 10 Pro, Version - 21H2, OS Build - 19044.2486

  3. juj commented on Apr 20, 2023

    @juj
    Collaborator

    Thanks, I am now able to reproduce. Posted a minimal bug report to upstream Windows Terminal at microsoft/terminal#15212

  4. juj commented on Apr 20, 2023

    @juj
    Collaborator

    Fix in above PR #19212.

  5. sbc100 commented on Feb 21, 2026

    @sbc100
    Collaborator

    Fixes (mostly) with #19212.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions