Draft
Fix Windows-only cmd /c calls in build_web.ps1 to support Linux#2
cmd /c calls in build_web.ps1 to support Linux#2Conversation
Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Windows cmd invocation to cross-platform PowerShell for emcc
Fix Windows-only Mar 9, 2026
cmd /c calls in build_web.ps1 to support Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build_web.ps1usedcmd /cto invoke the compiler and linker, which fails on Linux wherecmd.exedoesn't exist. The script also hardcoded a Windows backslash path separator inJoin-Path.Changes
Cross-platform
Join-Path— replaced"upstream\emscripten\emcc.py"string with multi-argumentJoin-Path $env:EMSDK "upstream" "emscripten" "emcc.py"so PowerShell resolves the separator per OSCompile step — replaced
cmd /c "... > tmpOut 2>&1"withStart-Process -FilePath $env:EMSDK_PYTHON -ArgumentList @("-E", $emccPy, "@$rspFull") -RedirectStandardOutput ... -RedirectStandardError ... -PassThru; exit code checked via$proc.ExitCodeinstead of$LASTEXITCODELink step — replaced
cmd /c "emcc @$linkRsp"with& emcc "@$linkRsp";$LASTEXITCODEis set correctly by PowerShell for external executable invocationsOriginal prompt
Problem
The file
web-build/project/emscripten/build_web.ps1usescmd /c(Windows Command Prompt) to invokeemccon lines 91 and 113. This fails on Linux becausecmddoesn't exist there. The user is running on Linux (/home/admin1/MCPE-WASM/...) with PowerShell Core installed.The errors look like:
And similarly on line 113:
Required Fix
Replace the Windows-specific
cmd /cinvocations with cross-platform PowerShell equivalents that work on both Windows and Linux:Line 88 — Fix the emsdk path separator
Lines 89-96 — Replace the compile
cmd /cblockThe current code:
Should be replaced with a cross-platform approach using
Start-Processor direct invocation with& $env:EMSDK_PYTHON -E $emccPy @argsand redirecting output, or simply using& emccdirectly since emsdk_env.ps1 should put emcc on the PATH. A good approach:Line 113 — Replace the link
cmd /cThe current code:
Should become:
Or if
emccis not directly on PATH, use the Python approach:Important Notes
Join-Pathwith multiple arguments is cross-platform and handles path separators automatically.@file) argument passing to emcc.$ErrorActionPreference = "Continue"at the top of the file should remain.$LASTEXITCODEis still properly captured after the changes.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: how do i test this branch and test deploy it on localhost?
Assistant:
Let me look at the repository structure and the PR to understand how this project is set up.
Assistant: Here's a complete guide to testing this PR branch locally and serving it on localhost:
Step 1: Clone the repo and check out the PR branch
git clone https://github.com/sriail/MCPE-WASM.git cd MCPE-WASM git checkout copilot/copy-mcpe-assets-to-web-buildOr if you already have the repo cloned:
Step 2: Prerequisites
You'll need these installed on your system:
.ps1(works on Windows natively; on macOS/Linux install PowerShell Core)Step 3: Install the Emscripten SDK
From the
web-build/directory, run:cd web-build .\install_deps.ps1This will:
emsdk/folder (next toweb-build/)Step 4: Build the WASM project
Still from
web-build/, run:This invokes `web-build/project/emscripten/build_w...
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.