Skip to content

Commit 690b193

Browse files
committed
🐛 fix(windows): remove broken fnm use --lts + catch silent npm failures
Observed on a fresh Windows 11 install test: - `fnm use --lts` fails on recent fnm builds from winget with "unexpected argument '--lts' found". Because PowerShell does not halt on native command non-zero exit codes under $ErrorActionPreference = "Stop", the script continued past the error. `fnm install --lts` already activates the version in the current shell's multishell junction, so the follow-up call was both redundant and broken. Removed. - `npm install -g @anthropic-ai/claude-code` produced no visible output and `Need claude` threw with a confusing "Missing command: claude" message. Two fixes: 1. Re-activate fnm (`fnm env --use-on-cd --shell powershell | iex`) immediately before each `npm install -g` call so the multishell junction is guaranteed to be on PATH even after earlier winget calls. 2. Check $LASTEXITCODE after the npm install and throw a clear error when it's non-zero, so silent failures surface immediately instead of cascading to a misleading "Missing command" message one section later.
1 parent 5f142e8 commit 690b193

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010

11+
## [1.1.1] - 2026-04-16
12+
13+
### Fixed
14+
15+
- Windows: removed `fnm use --lts` call that several recent fnm builds from winget reject with `unexpected argument '--lts' found`. `fnm install --lts` already activates the version in the current shell, so the follow-up call was both redundant and broken.
16+
- Windows: Claude Code and Codex install sections now re-activate fnm before calling `npm install -g`, then check `$LASTEXITCODE` and throw a clear error when npm fails. Prevents silent failures where the script continued and halted later with a confusing "Missing command: claude" message.
17+
1118
## [1.1.0] - 2026-04-16
1219

1320
### Added
@@ -52,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5259

5360

5461
## Links
55-
[Unreleased]: https://github.com/AojdevStudio/dev-bootstrap/compare/v1.1.0...HEAD
62+
[Unreleased]: https://github.com/AojdevStudio/dev-bootstrap/compare/v1.1.1...HEAD
63+
[1.1.1]: https://github.com/AojdevStudio/dev-bootstrap/compare/v1.1.0...v1.1.1
5664
[1.1.0]: https://github.com/AojdevStudio/dev-bootstrap/compare/v1.0.0...v1.1.0
5765
[v1.0.0]: https://github.com/AojdevStudio/dev-bootstrap/releases/tag/v1.0.0

bootstrap.ps1

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ if (Get-Command fnm -ErrorAction SilentlyContinue) {
149149

150150
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
151151
fnm install --lts
152-
fnm use --lts
153-
# Resolve the concrete LTS version; the `lts-latest` alias is fragile
154-
# across fnm versions (see Schniz/fnm#1203).
152+
# `fnm install --lts` activates the version in the current shell's multishell
153+
# junction. Do NOT follow with `fnm use --lts` — several recent fnm builds from
154+
# winget reject that flag form with "unexpected argument '--lts' found".
155+
# Resolve the concrete version from `fnm current` and set it as the default
156+
# (so new shells pick it up via the profile snippet's `fnm use default`).
155157
$ltsCurrent = (fnm current 2>$null | Out-String).Trim()
156158
if ($ltsCurrent -match '^v\d') {
157159
fnm default $ltsCurrent | Out-Null
158160
} else {
159-
fnm default lts-latest | Out-Null
161+
# Fallback for re-runs where `fnm current` reports nothing.
162+
fnm default lts-latest 2>$null | Out-Null
160163
}
161164
Need node
162165
Need npm
@@ -195,15 +198,30 @@ Need "bun" "If this is your first run, open a new PowerShell window and rerun so
195198
bun --version 2>$null | Out-Host
196199

197200
Section "Claude Code"
201+
# Re-activate fnm in this session: winget installs in earlier sections can
202+
# spawn sub-shells that drop the fnm multishells junction from PATH, leaving
203+
# `npm` reachable but its globals prefix invisible to later commands.
204+
if (Get-Command fnm -ErrorAction SilentlyContinue) {
205+
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
206+
}
198207
# npm avoids Zscaler/corporate-proxy blocks on irm|iex pattern
199208
npm install -g @anthropic-ai/claude-code
209+
if ($LASTEXITCODE -ne 0) {
210+
throw "npm install -g @anthropic-ai/claude-code failed with exit code $LASTEXITCODE. Fix the error above and re-run."
211+
}
200212
RefreshPath
201213
Need "claude" "If this is your first run, open a new PowerShell window and rerun so PATH updates apply."
202214
claude --version 2>$null | Out-Host
203215

204216
Section "Codex CLI"
217+
if (Get-Command fnm -ErrorAction SilentlyContinue) {
218+
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
219+
}
205220
# Official Codex CLI docs: https://developers.openai.com/codex/cli
206221
npm install -g @openai/codex
222+
if ($LASTEXITCODE -ne 0) {
223+
throw "npm install -g @openai/codex failed with exit code $LASTEXITCODE. Fix the error above and re-run."
224+
}
207225
RefreshPath
208226
Need "codex" "If this is your first run, open a new PowerShell window and rerun so PATH updates apply."
209227
codex --version 2>$null | Out-Host

0 commit comments

Comments
 (0)