Skip to content

Bug: Working directory shared across sessions via process-wide env var #6909

@blackgirlbytes

Description

@blackgirlbytes

Description

When multiple chat sessions are active, changing the working directory in one session (or the Home screen) affects all other sessions. This is because the developer extension reads its working directory from a process-wide environment variable (GOOSE_WORKING_DIR), creating two sources of truth.

Steps to Reproduce

  1. Open Goose Desktop and start a chat session in /project-a
  2. Navigate to the Home screen
  3. Change the directory to /project-b (or start a new session there)
  4. Return to the original chat session in /project-a
  5. Run a shell command - it will execute in /project-b instead of /project-a

Expected Behavior

Each chat session should maintain its own working directory, independent of other sessions.

Actual Behavior

Changing the working directory anywhere (Home screen or another session) overwrites the GOOSE_WORKING_DIR environment variable for the entire goosed process, affecting all active sessions.

Root Cause

The developer extension reads its working directory from a global env var:

// In crates/goose-mcp/src/developer/rmcp_developer.rs
let working_dir = std::env::var("GOOSE_WORKING_DIR")
    .ok()
    .map(std::path::PathBuf::from);

And when sessions start, they set this process-wide:

// In crates/goose/src/agents/extension_manager.rs
std::env::set_var("GOOSE_WORKING_DIR", &effective_working_dir);

Since std::env::set_var affects the entire process, all sessions end up sharing the same working directory.

Suggested Fix

The developer extension should receive its working directory through its initialization context or store it per-instance, rather than reading from a global environment variable.

Environment

  • Version: v1.22.2
  • OS: Ubuntu (reported), likely affects all platforms

Related

Reporter

Originally reported by a community member on the forum.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions