fix: Start login shells on macOS and Linux (#2437)

This appends `-l` to the shell command on macOS and Linux.
It also adds environment variable expansion to allow for
chaining from `coder_agent.env`.
This commit is contained in:
Kyle Carberry
2022-06-17 05:54:45 +00:00
committed by GitHub
parent be02d87f22
commit b9f3fe49cb
3 changed files with 41 additions and 17 deletions
+10
View File
@@ -2,6 +2,7 @@ package cli
import (
"context"
"fmt"
"net/http"
_ "net/http/pprof" //nolint: gosec
"net/url"
@@ -138,6 +139,15 @@ func workspaceAgent() *cobra.Command {
}
}
executablePath, err := os.Executable()
if err != nil {
return xerrors.Errorf("getting os executable: %w", err)
}
err = os.Setenv("PATH", fmt.Sprintf("%s%c%s", os.Getenv("PATH"), filepath.ListSeparator, filepath.Dir(executablePath)))
if err != nil {
return xerrors.Errorf("add executable to $PATH: %w", err)
}
closer := agent.New(client.ListenWorkspaceAgent, &agent.Options{
Logger: logger,
EnvironmentVariables: map[string]string{