Skip to content

Commit fb95d76

Browse files
committed
fix(cli): os doctor resolves the ledger's OS_HOME under the .env overlay and reports its provenance
Claude-Session: https://claude.ai/code/session_01Utp6CY4LWqfjLCYqpZhNCs Co-authored-by: Claude <noreply@anthropic.com>
1 parent 30eba36 commit fb95d76

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎packages/cli/src/commands/doctor.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ function renderHealthCheckResult(result: HealthCheckResult, verbose: boolean): v
120120
* Reading `.env` into a check that reports no attribution is precisely the
121121
* defect #5387 closed, and it would otherwise creep back one variable at a time.
122122
*/
123-
export const DOCTOR_ENV_INPUTS = ['OS_TENANCY_POSTURE', 'OS_MULTI_ORG_ENABLED', SCHEDULED_WORK_ENV] as const;
123+
export const DOCTOR_ENV_INPUTS = [
124+
'OS_TENANCY_POSTURE',
125+
'OS_MULTI_ORG_ENABLED',
126+
SCHEDULED_WORK_ENV,
127+
// [#30217] Where the installed-package ledger lives: `<OS_HOME>/installed-packages`
128+
// when set (`readInstalledPackageEntries`).
129+
'OS_HOME',
130+
] as const;
124131

125132
/** Where one environment value actually came from. */
126133
export interface EnvValueProvenance {
@@ -1248,7 +1255,10 @@ interface SkippedLedgerEntry {
12481255
* absorbed by the config `catch` and misreported as "Could not load config for
12491256
* analysis". The named reading replaces both the guess and the throw.
12501257
*/
1251-
async function readInstalledPackageEntries(cwd: string): Promise<InstalledPackageLedgerReading> {
1258+
async function readInstalledPackageEntries(
1259+
cwd: string,
1260+
dotenvReading: DotenvReading,
1261+
): Promise<InstalledPackageLedgerReading> {
12521262
// Dynamic, like serve.ts's cloud-connection load: `os doctor` must still run
12531263
// in a checkout where the optional package is not resolvable.
12541264
const load = await loadOptionalPackage('@objectstack/cloud-connection');
@@ -1285,7 +1295,9 @@ async function readInstalledPackageEntries(cwd: string): Promise<InstalledPackag
12851295
// that failed, reported as such rather than thrown out of doctor.
12861296
let dir: string;
12871297
try {
1288-
dir = (resolveDir as (opts: { cwd: string }) => { dir: string })({ cwd }).dir;
1298+
// Under the `.env*` overlay, like every other env-derived read here: `os
1299+
// serve` loads that cascade before the ledger resolves `OS_HOME`.
1300+
dir = withDotenvOverlay(dotenvReading, () => (resolveDir as (opts: { cwd: string }) => { dir: string })({ cwd })).dir;
12891301
} catch (cause) {
12901302
return { entries: [], skipped: [], readerFailure: { cause } };
12911303
}
@@ -2424,7 +2436,7 @@ export default class Doctor extends Command {
24242436
//
24252437
// The same reading is handed to the D5e advisory further down instead of
24262438
// being read a second time, which is what keeps one bad ledger to one row.
2427-
const ledgerReading = await readInstalledPackageEntries(cwd);
2439+
const ledgerReading = await readInstalledPackageEntries(cwd, dotenvReading);
24282440
results.push(...installedPackageLedgerChecks(ledgerReading));
24292441

24302442
// Display environment results

0 commit comments

Comments
 (0)