Skip to content

Conversation

@jamadeo
Copy link
Collaborator

@jamadeo jamadeo commented Sep 19, 2025

This speeds up startup quite a lot. I don't think we need to do it (and definitely not three times)

@michaelneale
Copy link
Collaborator

michaelneale commented Sep 19, 2025

@jamadeo not sure how it worked on your machine yesterday, but trying it packaged today:

  1. It couldn't see my ANTHROPIC_API_KEY which was in env var (I tried adding it to config.yaml - but it doesnt' read it from there). I then added it as a provider the standard way (keychain) and made a new session - that is first issue (minor?)

  2. (more serious) couldn't run developer extension as there is no working dir:

rmcp_developer.rs:183:43:\nshould have a current working dir

Longer:

Error activating extension: Failed to add extension configuration, error: ProcessExit(ProcessExit { stderr: "  \u{1b}[2m2025-09-19T17:57:10.433264Z\u{1b}[0m \u{1b}[32m INFO\u{1b}[0m \u{1b}[1;32mgoosed::commands::mcp\u{1b}[0m\u{1b}[32m: \u{1b}[32mStarting MCP server\u{1b}[0m\n    \u{1b}[2;3mat\u{1b}[0m crates/goose-server/src/commands/mcp.rs:19\n\n  \u{1b}[2m2025-09-19T17:57:10.433686Z\u{1b}[0m \u{1b}[32m INFO\u{1b}[0m \u{1b}[1;32mgoose_mcp::developer::analyze::cache\u{1b}[0m\u{1b}[32m: \u{1b}[32mInitializing analysis cache with size 100\u{1b}[0m\n    \u{1b}[2;3mat\u{1b}[0m crates/goose-mcp/src/developer/analyze/cache.rs:25\n\n\nthread 'main' panicked at crates/goose-mcp/src/developer/rmcp_developer.rs:183:43:\nshould have a current working dir: Os { code: 1, kind: PermissionDenied, message: \"Operation not permitted\" }\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n", source: ConnectionClosed("initialize response") })

@michaelneale michaelneale self-assigned this Sep 19, 2025
@michaelneale
Copy link
Collaborator

@jamadeo I think worth continuing this, but still couldn't work out how to make sure goosed and thus developer MCP has a pwd - removing that code means that while shell calls may work (I suspect what you model did first) the actual spawned mcps do not know their session dir somehow, not sure what process variable is missing yet... but certainly faster if we can make it work!

@michaelneale
Copy link
Collaborator

michaelneale commented Sep 19, 2025

@jamadeo actually scratch that last bit - I think on main I still see that, so may be my environment if you don't see it?

Main thing is that it doesn't load any old variable from config.yaml (in the occasional case you want to set provider + api key as a variable I guess? not sure what edge cases other than that, but probably not much).

@jamadeo
Copy link
Collaborator Author

jamadeo commented Sep 20, 2025

@michaelneale I can't reproduce any issue with the working directory (I'm asking the model to run pwd or echo $PWD in shell)

For the config, what do we really want to do there? I typically wouldn't expect a desktop app to execute by bash/zsh configs to read their environment. I'd expect to put everything in Goose's config.yaml or UI directly (for secret values e.g.)

If we definitely want a way to set environment variables in the Goose process, we could consider having an env section of config.yaml maybe? but that means we'll probably end up with config split between actual config variables and env variables, which doesn't seem great

@michaelneale
Copy link
Collaborator

michaelneale commented Sep 20, 2025

@jamadeo yeah - I think its just my environment.

On variables - it is pretty common for other systems to have an env: section like you said, which can be inline or pick from the environment around it (although the latter in this case I don't think would work as when it starts from an .app - there is nothing there really, I think anyway...). we do already have VARIABLE_NAME in config.yaml used for other parts but then it is a big leap to make it pick up any pattern.

The example I saw fail was anthropic, which uses pub fn get_secret in base.rs:

/// Get a secret value.
    ///
    /// This will attempt to get the value from:
    /// 1. Environment variable with the exact key name
    /// 2. System keyring

I'm not sure this will work with environment as there is no environment when run as an .app (but again may be my env! maybe can double check that?) worth checking out. In that specific case, secret store is probably ok, but if it trips up this, could be a ton of other unseen things.

@michaelneale
Copy link
Collaborator

michaelneale commented Sep 20, 2025

ok after clearing out Application Support/Goose dir, I can run this (and is fast) - however, even with shell commands it doesn't have access to the users shell variables (ie add some variable to .zshrc - then ask goose "tell me the value of $THING" ). I think that may be perhaps the bigger issue than config environment variables? (ie a developer using the developer SDK would have reason to think it would have a similar environment to their default/preferred shell?). It can source it if needed I guess...

interestingly in the developer toolkit:

            // Use bash on Unix/macOS (keep existing behavior)
            Self {
                executable: "bash".to_string(),
                args: vec!["-c".to_string()],
            }

even if I change that to zsh (hard coded - although it should honour $SHELL ideally), it doesn't automatically source .zshrc (!) when running shell commands, which seems really odd (this wouldn't be noticed when we forcibly source .zshrc so if this is a bug in developer mcp, then it is being hidden and now exposed).

In any case, this behaves differently to goose cli (given it starts from a shell of course). Obviously a non issue on linux (and windows) and for non zsh macos users as it was always this way - but a bit of a departure otherwise I think.. interesting..

@jamadeo
Copy link
Collaborator Author

jamadeo commented Sep 22, 2025

I wonder what we want to support here. What are the main use cases for passing env from shell config files? I think for Goose itself, you mainly want to pass vars to either MCP extensions or providers, and both of those have other (better) mechanisms.

The developer shell is an interesting use case. I wonder if it's possible for the goose shell tool to start a single login shell using $SHELL, and spawn all other shells from that? Or at least just do this login shell env reading in the developer MCP instead of app startup. That is, if we do want to make this work.

@jamadeo
Copy link
Collaborator Author

jamadeo commented Sep 22, 2025

@michaelneale I think BASH_ENV might be the key to all of this. If set, any bash process sources from this file. We can set it to a location in Goose's config dir, letting the user set up their Goose shell env however they want.

@jamadeo
Copy link
Collaborator Author

jamadeo commented Sep 22, 2025

Opened #4695 to allow a specific discussion

@michaelneale
Copy link
Collaborator

@jamadeo on mac I think everyone uses zsh these days, would BASH_ENV work for that the same? I'm not sure about changing cli behavior here though.

workspace = true

[dependencies]
goose = { path = "../goose" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm - is this an issue adding in the goose dep to mcp?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(feels circular but isn't...)

@michaelneale
Copy link
Collaborator

@jamadeo updated this to main - cli works still as expected, that is good to know. Do you think this should use the users default $SHELL and load it appropriately in fn shell functionality? (I believe can use interactive shell perhaps, but there is likely a reason we didn't, so your BASH_ENV approach may make sense, but do we want to assume bash?)

@michaelneale
Copy link
Collaborator

michaelneale commented Sep 23, 2025

@jamadeo ah - I think I learned something, good find on BASH_ENV - yes that is idiomatic way, and I think it is fine for GUI to expect to load it from somewhere like you suggested. I now get there is interactive, login shells, and we don't load either (for GUI) but need an option to load something. Bash doesn't have a standard other than what you set BASH_ENV to be. however zsh, which is now I believe standard on macos, does:

My suggestion, not sure if harmful is a PR to this PR: #4702

An additional option, use the built in $SHELL value and delegate to that (so it isn't hard coded to bash). That allows it to load appropriately if zsh etc, fall back to bash. So bash requires that goose location, but zsh DOES read from ~/.zshenv which is the correct and idiomatic place to put non interactive and non login values (which work for GUI and cli the same). Bash will require the goose specific location as you found - just a thought given that zsh is now default on macos, so we don't have to source zshrc (nor should we!) but we can use that one.

thouights?

@michaelneale
Copy link
Collaborator

"I wonder if it's possible for the goose shell tool to start a single login shell using $SHELL, and spawn all other shells from that?" - yeah I think it is probably right to not use the login shell, or even interactive, as this is not what it was designed for. I am sure that is possible however, probably probably messy state wise...

Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamadeo I think this is ok thinking about it. The dependency on goose core crate if it is in issue we can pull out the get_config_dir to somewhere else if the direction of dependencies are wrong, but is likely ok.

main downside of this may be people needing to know to put a .bash_env in the goose config dir (or if using the other PR - .zshenv in their home dir). Would it make sense to have a .goose_env option in home dir or getting weird and kludgy now?

@jamadeo jamadeo merged commit 44115a6 into main Sep 24, 2025
11 checks passed
@jamadeo jamadeo deleted the jackamadeo/dont-load-shell-env branch September 24, 2025 00:38
katzdave added a commit that referenced this pull request Sep 24, 2025
…ovements

* 'main' of github.com:block/goose:
  Remove now unused mcp-server crate (#4773)
  Release/1.9.0 (#4703)
  chore(mcp): convert computercontroller server to use the rust sdk (#4772)
  Docs: Delete sessions from UI and edit has changed (#4785)
  Don't load user's shell env on app startup (#4681)
  Docs: Chrome Dev Tools Extension Tutorial (#4783)
  Add Hacktoberfest 2025 Leaderboard Workflow (#4776)
  [docs] Add gotoHuman MCP server Tutorial (#4764)
  fix: adjust nightly builds to first push a tag (#4704)
  temp file for batch issue creation
  fix: view can recognise a dir (#4701)
  goosed standalone works with providers (#4698)
  Compact session automatically for streaming providers on Context Length Exceeded (#4565)
  When the developer extension gets a cancellation message, it should kill any running processes that it owns. (#4604)
  Remove some unused stuff (#4388)
  Add I Ching MCP to extension catalog (#4525)
  Offer to summarize or clear conversation when it has gotten too long … (#4688)
zanesq added a commit that referenced this pull request Sep 24, 2025
…-unification

* 'main' of github.com:block/goose:
  Add elapsed time to the CLI output. (#4609)
  fix: Fix cell coordinate ordering in XlsxTool and add unit tests (#4551)
  Use gemini flash for summarization on open router (#4290)
  chore(deps): bump xcb from 1.5.0 to 1.6.0 (#4289)
  feat(shell): throw errors on interactive commands (#4788)
  feat: AgentManager - foundation for unified execution (#4389) (#4684)
  shave and code split (#4630)
  docs: acp support (#4793)
  Add Take Action for Hacktoberfest (#4791)
  Remove now unused mcp-server crate (#4773)
  Release/1.9.0 (#4703)
  chore(mcp): convert computercontroller server to use the rust sdk (#4772)
  Docs: Delete sessions from UI and edit has changed (#4785)
  Don't load user's shell env on app startup (#4681)
  Docs: Chrome Dev Tools Extension Tutorial (#4783)
  Add Hacktoberfest 2025 Leaderboard Workflow (#4776)

# Conflicts:
#	crates/goose-server/src/routes/recipe.rs
#	ui/desktop/openapi.json
#	ui/desktop/src/api/types.gen.ts
#	ui/desktop/src/hooks/useRecipeManager.ts
#	ui/desktop/src/recipe/index.ts
zanesq added a commit that referenced this pull request Sep 24, 2025
…se into zane/recipe-param-values-resume

* 'zane/create-recipe-unification' of github.com:block/goose:
  fix recipe issues from upstream changes and regenerate types
  Add elapsed time to the CLI output. (#4609)
  fix: Fix cell coordinate ordering in XlsxTool and add unit tests (#4551)
  Use gemini flash for summarization on open router (#4290)
  chore(deps): bump xcb from 1.5.0 to 1.6.0 (#4289)
  feat(shell): throw errors on interactive commands (#4788)
  feat: AgentManager - foundation for unified execution (#4389) (#4684)
  shave and code split (#4630)
  docs: acp support (#4793)
  Add Take Action for Hacktoberfest (#4791)
  fix recipe instructions from session metadata not being injected
  Remove now unused mcp-server crate (#4773)
  Release/1.9.0 (#4703)
  chore(mcp): convert computercontroller server to use the rust sdk (#4772)
  Docs: Delete sessions from UI and edit has changed (#4785)
  Don't load user's shell env on app startup (#4681)
  Docs: Chrome Dev Tools Extension Tutorial (#4783)
  Add Hacktoberfest 2025 Leaderboard Workflow (#4776)

# Conflicts:
#	ui/desktop/src/hooks/useAgent.ts
#	ui/desktop/src/utils/providerUtils.ts
zanesq added a commit that referenced this pull request Sep 24, 2025
…ose into zane/create-edit-recipe-tests

* 'zane/recipe-param-values-resume' of github.com:block/goose:
  fix recipe issues from upstream changes and regenerate types
  Add elapsed time to the CLI output. (#4609)
  fix: Fix cell coordinate ordering in XlsxTool and add unit tests (#4551)
  Use gemini flash for summarization on open router (#4290)
  chore(deps): bump xcb from 1.5.0 to 1.6.0 (#4289)
  feat(shell): throw errors on interactive commands (#4788)
  feat: AgentManager - foundation for unified execution (#4389) (#4684)
  shave and code split (#4630)
  docs: acp support (#4793)
  Add Take Action for Hacktoberfest (#4791)
  fix recipe instructions from session metadata not being injected
  Remove now unused mcp-server crate (#4773)
  Release/1.9.0 (#4703)
  chore(mcp): convert computercontroller server to use the rust sdk (#4772)
  Docs: Delete sessions from UI and edit has changed (#4785)
  Don't load user's shell env on app startup (#4681)
  Docs: Chrome Dev Tools Extension Tutorial (#4783)
  Add Hacktoberfest 2025 Leaderboard Workflow (#4776)
tlongwell-block pushed a commit that referenced this pull request Sep 25, 2025
HikaruEgashira pushed a commit to HikaruEgashira/goose that referenced this pull request Oct 3, 2025
Co-authored-by: Michael Neale <[email protected]>
Signed-off-by: HikaruEgashira <[email protected]>
alexhancock added a commit that referenced this pull request Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants