Skip to content

Commit a86f347

Browse files
fix(windows): use pwsh with -NoProfile for build and shell
- Replace all powershell commands with pwsh -NoProfile in Taskfile.yml to prevent profile scripts from corrupting build output (fixes ldflags contamination causing Go linker failures) - Add -NoProfile flag to PowerShell shell launches in shellexec.go for local, remote, and WSL shells to prevent profile loading at runtime Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f8a97ca commit a86f347

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

Taskfile.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ vars:
88
BIN_DIR: "bin"
99
VERSION:
1010
sh: node version.cjs
11-
RMRF: '{{if eq OS "windows"}}powershell Remove-Item -Force -Recurse -ErrorAction SilentlyContinue{{else}}rm -rf{{end}}'
12-
DATE: '{{if eq OS "windows"}}powershell Get-Date -UFormat{{else}}date{{end}}'
11+
RMRF: '{{if eq OS "windows"}}pwsh -NoProfile -Command Remove-Item -Force -Recurse -ErrorAction SilentlyContinue{{else}}rm -rf{{end}}'
12+
DATE: '{{if eq OS "windows"}}pwsh -NoProfile -Command Get-Date -UFormat{{else}}date{{end}}'
1313
ARTIFACTS_BUCKET: waveterm-github-artifacts/staging-w2
1414
RELEASES_BUCKET: dl.waveterm.dev/releases-w2
1515
WINGET_PACKAGE: CommandLine.Wave
@@ -223,7 +223,7 @@ tasks:
223223
desc: Build the wavesrv component for Windows platforms (only generates artifacts for the current architecture).
224224
platforms: [windows]
225225
cmds:
226-
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path dist/bin/wavesrv*"
226+
- cmd: pwsh -NoProfile -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path dist/bin/wavesrv*"
227227
ignore_error: true
228228
- task: build:server:internal
229229
vars:
@@ -263,7 +263,7 @@ tasks:
263263
- cmd: rm -f dist/bin/wsh*
264264
platforms: [darwin, linux]
265265
ignore_error: true
266-
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path dist/bin/wsh*"
266+
- cmd: pwsh -NoProfile -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path dist/bin/wsh*"
267267
platforms: [windows]
268268
ignore_error: true
269269
- task: build:wsh:internal
@@ -327,7 +327,7 @@ tasks:
327327
- cmd: "{{.RMRF}} dist/tsunamiscaffold"
328328
ignore_error: true
329329
- task: copyfiles:'tsunami/frontend/scaffold':'dist/tsunamiscaffold'
330-
- cmd: '{{if eq OS "windows"}}powershell Copy-Item -Path tsunami/templates/empty-gomod.tmpl -Destination dist/tsunamiscaffold/go.mod{{else}}cp tsunami/templates/empty-gomod.tmpl dist/tsunamiscaffold/go.mod{{end}}'
330+
- cmd: '{{if eq OS "windows"}}pwsh -NoProfile -Command Copy-Item -Path tsunami/templates/empty-gomod.tmpl -Destination dist/tsunamiscaffold/go.mod{{else}}cp tsunami/templates/empty-gomod.tmpl dist/tsunamiscaffold/go.mod{{end}}'
331331
deps:
332332
- tsunami:scaffold
333333
sources:
@@ -486,7 +486,7 @@ tasks:
486486
copyfiles:*:*:
487487
desc: Recursively copy directory and its contents.
488488
internal: true
489-
cmd: '{{if eq OS "windows"}}powershell Copy-Item -Recurse -Force -Path {{index .MATCH 0}} -Destination {{index .MATCH 1}}{{else}}mkdir -p "$(dirname {{index .MATCH 1}})" && cp -r {{index .MATCH 0}} {{index .MATCH 1}}{{end}}'
489+
cmd: '{{if eq OS "windows"}}pwsh -NoProfile -Command Copy-Item -Recurse -Force -Path {{index .MATCH 0}} -Destination {{index .MATCH 1}}{{else}}mkdir -p "$(dirname {{index .MATCH 1}})" && cp -r {{index .MATCH 0}} {{index .MATCH 1}}{{end}}'
490490

491491
clean:
492492
desc: clean make/dist directories
@@ -539,7 +539,7 @@ tasks:
539539
- cmd: rm -f package.json
540540
platforms: [darwin, linux]
541541
ignore_error: true
542-
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path package.json"
542+
- cmd: pwsh -NoProfile -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path package.json"
543543
platforms: [windows]
544544
ignore_error: true
545545
- npm --no-workspaces init -y --init-license Apache-2.0
@@ -585,26 +585,26 @@ tasks:
585585
cmds:
586586
- cmd: "{{.RMRF}} scaffold"
587587
ignore_error: true
588-
- powershell New-Item -ItemType Directory -Force -Path scaffold
589-
- powershell Copy-Item -Path ../templates/package.json.tmpl -Destination scaffold/package.json
590-
- powershell -Command "Set-Location scaffold; npm install"
591-
- powershell Move-Item -Path scaffold/node_modules -Destination scaffold/nm
592-
- powershell Copy-Item -Recurse -Force -Path dist -Destination scaffold/
593-
- powershell New-Item -ItemType Directory -Force -Path scaffold/dist/tw
594-
- powershell Copy-Item -Path '../templates/*.go.tmpl' -Destination scaffold/
595-
- powershell Copy-Item -Path ../templates/tailwind.css -Destination scaffold/
596-
- powershell Copy-Item -Path ../templates/gitignore.tmpl -Destination scaffold/.gitignore
597-
- powershell Copy-Item -Path 'src/element/*.tsx' -Destination scaffold/dist/tw/
598-
- powershell Copy-Item -Path '../ui/*.go' -Destination scaffold/dist/tw/
599-
- powershell Copy-Item -Path ../engine/errcomponent.go -Destination scaffold/dist/tw/
588+
- pwsh -NoProfile -Command New-Item -ItemType Directory -Force -Path scaffold
589+
- pwsh -NoProfile -Command Copy-Item -Path ../templates/package.json.tmpl -Destination scaffold/package.json
590+
- pwsh -NoProfile -Command "Set-Location scaffold; npm install"
591+
- pwsh -NoProfile -Command Move-Item -Path scaffold/node_modules -Destination scaffold/nm
592+
- pwsh -NoProfile -Command Copy-Item -Recurse -Force -Path dist -Destination scaffold/
593+
- pwsh -NoProfile -Command New-Item -ItemType Directory -Force -Path scaffold/dist/tw
594+
- pwsh -NoProfile -Command Copy-Item -Path '../templates/*.go.tmpl' -Destination scaffold/
595+
- pwsh -NoProfile -Command Copy-Item -Path ../templates/tailwind.css -Destination scaffold/
596+
- pwsh -NoProfile -Command Copy-Item -Path ../templates/gitignore.tmpl -Destination scaffold/.gitignore
597+
- pwsh -NoProfile -Command Copy-Item -Path 'src/element/*.tsx' -Destination scaffold/dist/tw/
598+
- pwsh -NoProfile -Command Copy-Item -Path '../ui/*.go' -Destination scaffold/dist/tw/
599+
- pwsh -NoProfile -Command Copy-Item -Path ../engine/errcomponent.go -Destination scaffold/dist/tw/
600600

601601
tsunami:build:
602602
desc: Build the tsunami binary.
603603
cmds:
604604
- cmd: rm -f bin/tsunami*
605605
platforms: [darwin, linux]
606606
ignore_error: true
607-
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path bin/tsunami*"
607+
- cmd: pwsh -NoProfile -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path bin/tsunami*"
608608
platforms: [windows]
609609
ignore_error: true
610610
- mkdir -p bin

pkg/shellexec/shellexec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func StartWslShellProc(ctx context.Context, termSize waveobj.TermSize, cmdStr st
233233
pwshPath := fmt.Sprintf("~/.waveterm/%s/wavepwsh.ps1", shellutil.PwshIntegrationDir)
234234
// powershell is weird about quoted path executables and requires an ampersand first
235235
shellPath = "& " + shellPath
236-
shellOpts = append(shellOpts, "-ExecutionPolicy", "Bypass", "-NoExit", "-File", pwshPath)
236+
shellOpts = append(shellOpts, "-NoProfile", "-ExecutionPolicy", "Bypass", "-NoExit", "-File", pwshPath)
237237
} else {
238238
if cmdOpts.Login {
239239
shellOpts = append(shellOpts, "-l")
@@ -385,7 +385,7 @@ func StartRemoteShellProc(ctx context.Context, logCtx context.Context, termSize
385385
pwshPath := fmt.Sprintf("~/.waveterm/%s/wavepwsh.ps1", shellutil.PwshIntegrationDir)
386386
// powershell is weird about quoted path executables and requires an ampersand first
387387
shellPath = "& " + shellPath
388-
shellOpts = append(shellOpts, "-ExecutionPolicy", "Bypass", "-NoExit", "-File", pwshPath)
388+
shellOpts = append(shellOpts, "-NoProfile", "-ExecutionPolicy", "Bypass", "-NoExit", "-File", pwshPath)
389389
} else {
390390
if cmdOpts.Login {
391391
shellOpts = append(shellOpts, "-l")
@@ -482,7 +482,7 @@ func StartLocalShellProc(logCtx context.Context, termSize waveobj.TermSize, cmdS
482482
carg := fmt.Sprintf("source %s", shellutil.HardQuoteFish(waveFishPath))
483483
shellOpts = append(shellOpts, "-C", carg)
484484
} else if shellType == shellutil.ShellType_pwsh {
485-
shellOpts = append(shellOpts, "-ExecutionPolicy", "Bypass", "-NoExit", "-File", shellutil.GetLocalWavePowershellEnv())
485+
shellOpts = append(shellOpts, "-NoProfile", "-ExecutionPolicy", "Bypass", "-NoExit", "-File", shellutil.GetLocalWavePowershellEnv())
486486
} else {
487487
if cmdOpts.Login {
488488
shellOpts = append(shellOpts, "-l")

0 commit comments

Comments
 (0)