Skip to content

Commit b64ba41

Browse files
committed
fix: check for npm before attempting codex install
1 parent aef82b4 commit b64ba41

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pkg/cmd/open/open.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,13 @@ func ensureCodexInstalled(t *terminal.Terminal, sshAlias string) error {
10621062
return nil // already installed
10631063
}
10641064

1065+
// Verify npm is available on remote before attempting install
1066+
npmCheck := fmt.Sprintf("ssh %s 'which npm >/dev/null 2>&1'", sshAlias)
1067+
npmExec := exec.Command("bash", "-c", npmCheck) // #nosec G204
1068+
if npmErr := npmExec.Run(); npmErr != nil {
1069+
return fmt.Errorf("failed to install Codex: npm is not installed on the remote instance. Please install Node.js/npm first")
1070+
}
1071+
10651072
t.Vprintf("Installing Codex CLI on remote instance...\n")
10661073

10671074
installCmd := fmt.Sprintf("ssh %s 'npm install -g @openai/codex 2>/dev/null || sudo npm install -g @openai/codex'", sshAlias)

0 commit comments

Comments
 (0)