Skip to content

Commit f6effdb

Browse files
authored
fix: redirect the user to the home directory if dir is not set (coder#6085)
This was blocking SSH connections from being established if a dir that wasn't created yet is set.
1 parent bde4ffe commit f6effdb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

agent/agent.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,11 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
803803

804804
cmd := exec.CommandContext(ctx, shell, args...)
805805
cmd.Dir = metadata.Directory
806-
if cmd.Dir == "" {
806+
807+
// If the metadata directory doesn't exist, we run the command
808+
// in the users home directory.
809+
_, err = os.Stat(cmd.Dir)
810+
if cmd.Dir == "" || err != nil {
807811
// Default to user home if a directory is not set.
808812
homedir, err := userHomeDir()
809813
if err != nil {

0 commit comments

Comments
 (0)