Closed Bug 1799068 Opened 3 years ago Closed 2 years ago

VS Code tasks don't work on Windows 10

Categories

(Firefox Build System :: General, defect, P3)

x86_64
Windows 10
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1858932

People

(Reporter: aminomancer, Unassigned)

References

Details

STR

  1. In vscode on Windows, open mozilla-central
  2. Open the command palette
  3. Type "Tasks: Run Task" and hit return
  4. Type "run" and hit return

Expected

The build should run

Actual

Error:

 *  Executing task in folder mozilla-central: /mozilla-build/start-shell.bat cd "$('C:\mozilla-source\mozilla-central' -replace '\\','/')" ';' mach --log-no-times run -purgecaches 

MozillaBuild Install Directory: C:\mozilla-build\
/d: /d: Is a directory

 *  The terminal process "C:\mozilla-build\start-shell.bat -here /d /c /mozilla-build/start-shell.bat cd "$('C:\mozilla-source\mozilla-central' -replace '\\','/')" ';' mach --log-no-times run -purgecaches" terminated with exit code: 126. 
 *  Terminal will be reused by tasks, press any key to close it. 

I guess this isn't a permanent solution according to bug 1748762, and maybe there's a better way to fix this, but I was able to get the tasks to work like this:

--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -6,14 +6,17 @@
     "command": "${workspaceFolder}/mach",
     "args": ["--log-no-times"],
     "windows": {
-      "command": "/mozilla-build/start-shell.bat",
+      "options": {
+        "shell": {
+          "executable": "PowerShell",
+        },
+        "env": {
+          "MACH_PS1_USE_MOZILLABUILD": "/mozilla-build/",
+          "MOZILLABUILD": "/mozilla-build/",
+        }
+      },
+      "command": "${workspaceFolder}/mach.ps1",
       "args": [
-        "cd",
-        // Use PowerShell to mangle path for mozilla-build environment
-        {"value": "$('${workspaceFolder}' -replace '\\\\','/')", "quoting": "weak"},
-        "';'",
-
-        "mach",
         "--log-no-times"
       ]
     },
diff --git a/mach.ps1 b/mach.ps1
index 51f66aeed8eb8..6d92ef8838a14 100644
--- a/mach.ps1
+++ b/mach.ps1
@@ -40,9 +40,9 @@ Please run MozillaBuild manually for now.

 $mozillabuild_version = Get-Content "$env:MOZILLABUILD\VERSION"
 # Remove "preX" postfix if the current MozillaBuild is a prerelease.
-$mozillabuild_version = [decimal]($mozillabuild_version -replace "pre.*")
+$mozillabuild_version = [decimal]($mozillabuild_version.split(".")[0])

-if ($mozillabuild_version -ge 4.0) {
+if ($mozillabuild_version -ge 4) {
   & "$env:MOZILLABUILD/start-shell.bat" -no-start -defterm -c "$machpath $args"
 } else {
   & "$env:MOZILLABUILD/start-shell.bat" $machpath $args

(I also had to change mach.ps1 since MozillaBuild's current version has two dots)

See Also: → 1594520

Oh yeah this is with a different default shell. Here is what happens if I disable all the terminal related user settings:

 *  Executing task in folder mozilla-central: /mozilla-build/start-shell.bat cd "$('C:\mozilla-source\mozilla-central' -replace '\\','/')" ';' mach --log-no-times run -purgecaches 

MozillaBuild Install Directory: C:\mozilla-build\
/usr/bin/bash: cd: No such file or directory

 *  The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command /mozilla-build/start-shell.bat cd "$('C:\mozilla-source\mozilla-central' -replace '\\','/')" ';' mach --log-no-times run -purgecaches" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

The Bugbug bot thinks this bug should belong to the 'Firefox Build System::Mach Core' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Mach Core

This eliminates the errors but doesn't actually work:

--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -6,8 +6,14 @@
     "command": "${workspaceFolder}/mach",
     "args": ["--log-no-times"],
     "windows": {
+      "options": {
+        "shell": {
+          "executable": "PowerShell",
+        }
+      },
       "command": "/mozilla-build/start-shell.bat",
       "args": [
+        "-c",
         "cd",
         // Use PowerShell to mangle path for mozilla-build environment
         {"value": "$('${workspaceFolder}' -replace '\\\\','/')", "quoting": "weak"},
Component: Mach Core → General
Severity: -- → S3
Priority: -- → P3

Bug 1858932 offers a fix that seems to fix this.

Status: NEW → RESOLVED
Closed: 2 years ago
Duplicate of bug: 1858932
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.