Skip to content

Commit 2b1d3bd

Browse files
committed
fix(agent/agentcontainers): always use /bin/sh for devcontainer autostart script
This fixes startup issues when the user shell is set to Fish. Refs: #17845
1 parent eb6412a commit 2b1d3bd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

agent/agentcontainers/devcontainer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const (
2222

2323
const devcontainerUpScriptTemplate = `
2424
if ! which devcontainer > /dev/null 2>&1; then
25-
echo "ERROR: Unable to start devcontainer, @devcontainers/cli is not installed."
25+
echo "ERROR: Unable to start devcontainer, @devcontainers/cli is not installed or not found in \$PATH." 1>&2
26+
echo "Please install @devcontainers/cli by running \"npm install -g @devcontainers/cli\" or by using the \"devcontainers-cli\" Coder module." 1>&2
2627
exit 1
2728
fi
2829
devcontainer up %s
@@ -65,7 +66,9 @@ func devcontainerStartupScript(dc codersdk.WorkspaceAgentDevcontainer, script co
6566
args = append(args, fmt.Sprintf("--config %q", dc.ConfigPath))
6667
}
6768
cmd := fmt.Sprintf(devcontainerUpScriptTemplate, strings.Join(args, " "))
68-
script.Script = cmd
69+
// Force the script to run in /bin/sh, since some shells (e.g. fish)
70+
// don't support the script.
71+
script.Script = fmt.Sprintf("/bin/sh -c '%s'", cmd)
6972
// Disable RunOnStart, scripts have this set so that when devcontainers
7073
// have not been enabled, a warning will be surfaced in the agent logs.
7174
script.RunOnStart = false

0 commit comments

Comments
 (0)