Skip to content

Commit 781f3d0

Browse files
authored
fix: use dir over full path for coder bin (coder#1795)
1 parent 7b39352 commit 781f3d0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

agent/agent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
359359
if err != nil {
360360
return nil, xerrors.Errorf("getting os executable: %w", err)
361361
}
362-
cmd.Env = append(cmd.Env, fmt.Sprintf(`PATH=%s%c%s`, os.Getenv("PATH"), filepath.ListSeparator, executablePath))
362+
cmd.Env = append(cmd.Env, fmt.Sprintf(`PATH=%s%c%s`, os.Getenv("PATH"), filepath.ListSeparator, filepath.Dir(executablePath)))
363363
// Git on Windows resolves with UNIX-style paths.
364364
// If using backslashes, it's unable to find the executable.
365365
unixExecutablePath := strings.ReplaceAll(executablePath, "\\", "/")

agent/agent_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestAgent(t *testing.T) {
8080
ex, err := os.Executable()
8181
t.Log(ex)
8282
require.NoError(t, err)
83-
require.True(t, strings.Contains(strings.TrimSpace(string(output)), ex), string(output), ex)
83+
require.True(t, strings.Contains(strings.TrimSpace(string(output)), filepath.Dir(ex)))
8484
})
8585

8686
t.Run("SessionTTY", func(t *testing.T) {

0 commit comments

Comments
 (0)