Replies: 1 comment
|
Thanks for the report. I reproduced this against commit 47f9438. The loader has two independent .env reads, and both currently attempt to read the path without first checking that it is a regular file, so a directory named .env surfaces EISDIR.\n\nI prepared a minimal local patch (commit b15c8a3): missing paths and non-regular paths are silently skipped, while read failures for regular files keep the existing warning behavior. Layered precedence and bootstrap-only validation remain unchanged. Focused tests pass (52/52), along with package TypeScript, Oxlint, and doc-sync (28/28).\n\nSince external PRs are currently not accepted, could a maintainer confirm whether this behavior and patch direction fit the project expectations? I can provide the patch or adapt it to the project conventions. |
Uh oh!
There was an error while loading. Please reload this page.
Environment
@deepseek-ai/dsh: 0.1.0-rc.6 (installed vianpm install -g @deepseek-ai/dsh; also reproduced vianpx @deepseek-ai/dsh web)@deepseek-ai/dsh-app-boot: 0.1.0-rc.6Summary
When a directory named
.envexists in the directory wheredshis invoked (or in the Harness home,~/.dsh), every boot prints:A directory can never be a valid dotenv file, so according to the documented semantics ("missing files fall back to the ambient environment", see the doc comments on
readEnvLayer/loadEnv) this case should be treated like a missing file and skipped silently — not reported as a misconfiguration. The message is non-fatal (the profile still boots), but it reads like a hard error and is confusing.Steps to reproduce
Create an empty directory named
.envin the current directory:Boot any profile from that directory:
dsh --profile web(In my case the
.envdirectory was at the home directoryC:\Users\<user>\.env, anddshwas run from that same directory, which is how the invoking-directory layer picked it up.)Expected behavior
No
.envdiagnostics at all — the directory is not a dotenv file, so the loader falls back to the ambient environment, and boot proceeds cleanly (dsh web: http://127.0.0.1:3080, etc.).Actual behavior
The boot continues afterwards (the line is a warning, not a fatal error).
Root cause
In
packages/boot/app-boot(@deepseek-ai/dsh-app-boot), both.envreaders only treatENOENTas "no file", so any other read error is reported:readEnvLayer()—readFileSync(resolve(dir, ".env"), "utf8"); the catch warns unlesserror?.code !== "ENOENT". This is the function that produced the reported line:apps/cli'sbin.jscallsloadLayeredEnv("dsh"), which reads the invoking-directory layer and the~/.dshuser layer throughreadEnvLayer. In the published package this islib/index.jsaround lines 695–713.loadEnv()—process.loadEnvFile(resolve(dir, ".env")); sameENOENT-only filter. Publishedlib/index.jsaround lines 611–617.When the resolved path is a directory,
fs.readFileSyncthrowsEISDIR(verified standalone:EISDIR: illegal operation on a directory, read), which does not match theENOENTfilter and is therefore printed as "failed to load .env". (process.loadEnvFileon a directory throwsERR_INVALID_ARG_TYPEon Node 24 — a different code, but the same bug: a non-file.envis reported instead of skipped.)Suggested fix
Treat a non-file
.envas "no env file" in both readers, e.g.:or, more robustly, check before reading:
Additional context
.envis a legal folder name; here an emptyC:\Users\<user>\.envdirectory existed in the home directory.cwd/.envand~/.dsh/.env) go through the samereadEnvLayerguard, so the same fix covers both.All reactions