fix: use dir over full path for coder bin (#1795)

This commit is contained in:
Garrett Delfosse
2022-05-26 14:05:46 -05:00
committed by GitHub
parent 7b393526c5
commit 781f3d0641
2 changed files with 2 additions and 2 deletions

View File

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

View File

@ -80,7 +80,7 @@ func TestAgent(t *testing.T) {
ex, err := os.Executable() ex, err := os.Executable()
t.Log(ex) t.Log(ex)
require.NoError(t, err) require.NoError(t, err)
require.True(t, strings.Contains(strings.TrimSpace(string(output)), ex), string(output), ex) require.True(t, strings.Contains(strings.TrimSpace(string(output)), filepath.Dir(ex)))
}) })
t.Run("SessionTTY", func(t *testing.T) { t.Run("SessionTTY", func(t *testing.T) {