use the platform's binary resolver instead of a second copy

teaBinary hardcoded ~/.local/bin:$PATH. Right for tea, wrong as a habit: iris wrote the same function
with ~/.cargo/bin added, the two disagreed, and a rustup-only machine was refused a plugin its own
sidecar could build.

locateBinary asks the owner's login shell, so it knows about every directory a per-user installer
added without anyone listing them. Verified it still resolves tea from ~/.local/bin, which is the case
the comment above it was written for.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-21 00:19:47 +00:00
co-authored by Claude Opus 5
parent 7d79cab95c
commit 6d5b75f4f2
+8 -2
View File
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
import { join } from 'node:path';
import { getUserById } from 'officerdb';
import { osUserHome, runAs } from '@@/os-user';
import { locateBinary } from '@@/plugins/os-deps';
// Reading and writing `tea`'s own config, per user.
//
@@ -45,9 +46,14 @@ const isOwnerUser = (osUser: string | null): boolean => !osUser || osUser === pr
*
* Resolved once per call rather than cached: an install can add it while this process is running, and a
* cached "missing" would outlive the thing that fixed it.
*
* `locateBinary` is the PLATFORM's resolver, not a copy of it. This used to hardcode
* `~/.local/bin:$PATH`, which was right for tea and wrong as a habit — iris wrote the same function with
* `~/.cargo/bin` added, the two disagreed, and a rustup-only machine was refused a plugin it could build.
* The shared one asks the owner's login shell, so it knows about every directory a per-user installer
* added without anybody listing them.
*/
const teaBinary = (): string =>
Bun.which('tea', { PATH: `${join(homedir(), '.local', 'bin')}:${process.env.PATH ?? ''}` }) ?? 'tea';
const teaBinary = (): string => locateBinary('tea') ?? 'tea';
const configPathFor = (home: string): string => join(home, '.config', 'tea', 'config.yml');