Skip to content

fix: find tools on the login shell's PATH when the shell is slow at login - #363

Merged
M4n0x merged 1 commit into
mainfrom
fix/362-login-shell-path
Oct 28, 2026
Merged

M4n0x merged 1 commit into
mainfrom
fix/362-login-shell-path

Conversation

@M4n0x

@M4n0x M4n0x commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

Fixes #362.

StableBar reads the login shell's environment once at launch, with a 10 second limit. Right after login, a profile that runs brew shellenv, keychain lookups or nvm can take longer than that. The read was then killed, try? dropped the error, and every command kept the app's launchd PATH=/usr/bin:/bin:/usr/sbin:/sbin until a relaunch. Workspaces then reported "AeroSpace is not on your login shell's PATH.", and Reconnect couldn't help.

Changes

  • readLoginShellEnvironment() (Command.swift) gives the shell 60 seconds instead of 10. After a failed read it logs the error to stderr and retries with the provider backoff: 10 s, doubling, capped at 5 minutes.
  • At launch (StableBarApp.swift) the bar still starts after 10 seconds at most, so a slow profile doesn't delay it any more than before. If the read finishes later, it isn't killed. Once it lands, BarStore.loginShellEnvironmentLoaded() reconnects workspaces and runs every script and provider again (SENDER=startup), because they first ran without the shell's PATH.
  • Task.finishes(within:) waits for the read without cancelling it.
  • docs/create-a-widget.md says what happens when the profile is slow.

This adds no configuration property, so decoding, layers, Settings, command-line edits and examples need no changes.

Testing

  • New tests in LoginShellEnvironmentTests.swift:
    • A fake shell that hangs on its first read and answers on the second: the timed-out read is retried and returns the environment.
    • finishes(within:) returns false at its limit and leaves the task running.
    • A store whose AeroSpace lookup fails, then succeeds: loginShellEnvironmentLoaded() runs the script again and reconnects workspaces (mode read, connection error cleared). With the method body removed, this test fails on all three expectations.
  • Full swift test passes locally: 538 Swift Testing and 295 XCTest tests.
  • Live check with a dev build: scratch configuration, the app launched with the launchd PATH, and ZDOTDIR pointing at a .zprofile that sleeps 15 seconds before adding /opt/homebrew/bin. Polling --query every second showed:
    • t+11 s: "modeConnectionError": "AeroSpace is not on your login shell's PATH.". This is the state from the issue.
    • t+15.5 s: "mode": "main", "modeConnectionError": null, without a relaunch. The workspace loop's own retry wasn't due until about t+16.5 s, so the reconnect cleared it.
  • Not checked: a real login with a slow profile, and a profile that never finishes. That one would now retry every 5 minutes, each read killed after 60 seconds, where it used to give up once.
  • No visible change, so no screenshots.

Merging

One fix: commit. A merge or rebase merge keeps it in the patch-release changelog.

Claude Opus 5.5 via Claude Code.

…ogin

At login, a profile that runs brew shellenv, keychain lookups or nvm can take more than the
10 seconds StableBar gave the login shell. The read was then killed, its error dropped, and
commands kept the app's launchd PATH until a relaunch, so Workspaces reported AeroSpace missing.

The read now gets 60 seconds and retries with backoff after a failure. The bar still starts
after 10 seconds at most; when the read finishes later, the store reconnects workspaces and
runs scripts and providers again.

Fixes #362
@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner October 28, 2026 10:23
@M4n0x
M4n0x merged commit 2fd65d0 into main Oct 28, 2026
8 checks passed
@M4n0x
M4n0x deleted the fix/362-login-shell-path branch October 28, 2026 10:45
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commands lose the login shell's PATH until relaunch when the shell is slow at login

1 participant