fix: expand ~ in toolsrv CWD to prevent fork/exec ENOENT

Shell doesn't expand ~ in programmatically-passed arguments, so
toolsrv received literal ~/src/ollie as --cwd. Go's os/exec fails
with ENOENT on chdir before exec, breaking all tool execution.

Expand ~ at two boundaries:
- main.go: immediately after flag parsing
- proc.go SetCWD(): for runtime cwd changes via 9P
This commit is contained in:
Ollie Agent 2026-08-11 11:24:10 +02:00
parent 686a560e84
commit cfc429f5f4
2 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import (
"ollie/cmd/toolsrv/internal/exec"
"ollie/cmd/toolsrv/internal/registry"
"ollie/paths"
"ollie/toolsrv"
)
@ -95,7 +96,7 @@ func (st *State) CWD() string {
// SetCWD sets the current working directory.
func (st *State) SetCWD(dir string) {
st.mu.Lock()
st.cwd = dir
st.cwd = paths.ExpandHome(dir)
st.mu.Unlock()
}

View File

@ -29,6 +29,7 @@ import (
"ollie/env"
"ollie/fsedsl"
olog "ollie/log"
"ollie/paths"
)
var (
@ -61,6 +62,9 @@ func main() {
os.Exit(1)
}
// Expand ~ in CWD (shell doesn't expand ~ in arguments).
*cwd = paths.ExpandHome(*cwd)
// Set up logger
sink := olog.NewSink(os.Stdout, os.Stderr, olog.LevelInfo)
defer sink.Flush()