Skip to content

fix: resolve gateway binary path, pass --config flag, and clarify emp…#1337

Merged
wj-xiao merged 1 commit intosipeed:mainfrom
snac21:fix/gateway-binary-path-and-config
Mar 11, 2026
Merged

fix: resolve gateway binary path, pass --config flag, and clarify emp…#1337
wj-xiao merged 1 commit intosipeed:mainfrom
snac21:fix/gateway-binary-path-and-config

Conversation

@snac21
Copy link
Contributor

@snac21 snac21 commented Mar 11, 2026

This PR addresses the 3 issues reported regarding the gateway startup process, incorporating the latest feedback:

  1. Binary path resolution: findPicoclawBinary() now checks the PICOCLAW_BINARY environment variable first as an explicit override. As suggested, the fragile relative path probing (../../build/picoclaw) was removed. It now falls back to the same directory as the executable (which naturally covers the production build layout) before relying on $PATH.
  2. Config path forwarding: By setting the PICOCLAW_CONFIG environment variable in the child process before cmd.Start(). This seamlessly integrates with the existing CLI config resolution logic.
  3. Crash on empty model: Improved robustness in pkg/providers/factory.go. Instead of panicking with a confusing "no API key configured for model: " error when an empty model reaches the default switch case, it now checks if both the provider and model are empty and returns a clear "no model configured: agents.defaults.model is empty" error early.

All tests have been updated and pass successfully.

Fixes #1290

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2026

CLA assistant check
All committers have signed the CLA.

@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: provider go Pull requests that update go code labels Mar 11, 2026
@snac21 snac21 force-pushed the fix/gateway-binary-path-and-config branch from 64e6118 to 9c3ef70 Compare March 11, 2026 02:45
cmd := exec.Command(execPath, "gateway")
args := []string{"gateway"}
if h.configPath != "" {
args = append(args, "--config", h.configPath)
Copy link
Collaborator

Choose a reason for hiding this comment

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

picoclaw gateway does not support a --config flag today, so this change will make launcher-driven gateway startup fail immediately.
The subcommand only defines --debug and --no-truncate, and still uses cobra.NoArgs, so passing --config <path> causes the child process to exit with unknown flag: --config.

Since the launcher always has a non-empty config path, this affects both auto-start and manual start. If the goal is to make the gateway use the launcher’s config file, a safer approach would be to set PICOCLAW_CONFIG in the child process environment before cmd.Start(), because the CLI already resolves its config path from that environment variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it as requested.Could you please review it again?

return candidate
}

// 3. Relative paths — covers running from web/backend/dist/
Copy link
Collaborator

Choose a reason for hiding this comment

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

The relative-path fallback here looks unnecessary. In our actual build layout, both picoclaw-launcher and picoclaw are emitted into the same build/ directory, so the previous “same directory as the current executable” check should already cover the production case.
For typical development flows, this ../../build / ../build heuristic is also fairly brittle because os.Executable() often points to a temporary Go build location rather than web/backend/dist/.

Given that this PR already adds PICOCLAW_BINARY as an explicit override, I think that plus same-directory lookup and the final $PATH fallback is the robust part; this extra relative-path probing seems speculative and may not be worth keeping unless there is a concrete packaging layout that depends on it.

@snac21 snac21 force-pushed the fix/gateway-binary-path-and-config branch from 9c3ef70 to be83866 Compare March 11, 2026 03:35
@wj-xiao wj-xiao merged commit d5cbf19 into sipeed:main Mar 11, 2026
4 checks passed
@snac21 snac21 deleted the fix/gateway-binary-path-and-config branch March 11, 2026 05:56
@snac21 snac21 restored the fix/gateway-binary-path-and-config branch March 12, 2026 05:06
fishtrees pushed a commit to fishtrees/picoclaw that referenced this pull request Mar 12, 2026
@Orgmar
Copy link
Contributor

Orgmar commented Mar 13, 2026

@snac21 Nice work tackling three issues in one PR. Using PICOCLAW_BINARY as an explicit override and removing the fragile relative path probing is much more robust. The clear error message for empty model config is also a good UX improvement.

We have a PicoClaw Dev Group on Discord for contributors. Want to join? Send an email to [email protected] with the subject [Join PicoClaw Dev Group] + your GitHub account and we'll get you the invite link!

dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 14, 2026
dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: provider go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web backend Gateway config

4 participants