Skip to content

Crash on startup due to odd .env #264

Closed

Description

@jackarch-2

Hi,

We have some .env oddities in our codebase which are causing an issue where this CLI crashes on startup. I'm going to patch the CLI for myself using the prompt below, which I also wrote. If there's an alternative framing you'd propose to lead to a better solution, let me know and I'll go that way plus share the results in a PR. If taking a change like this upstream is undesirable, I totally understand that, too.

Anyway, here's my prompt for what it's worth, and please let me know if you're interested in collaborating more on an improvement here.

The Linear CLI crashes in our monorepo with this issue:

error: Uncaught (in promise) IsADirectory: Is a directory (os error 21): readfile '.env'
    return parse(await Deno.readTextFile(filepath));
                 ^
    at async Object.readTextFile (ext:deno_fs/30_fs.js:814:18)
    at async parseFile (https://jsr.io/@std/dotenv/0.225.6/mod.ts:244:18)
    at async load (https://jsr.io/@std/dotenv/0.225.6/mod.ts:217:26)
    at async loadEnvFiles (file:///var/folders/2b/8_tpkwdj7d574_pqq2j_dz2h0000gq/T/deno-compile-linear/src/config.ts:80:15)
    at async file:///var/folders/2b/8_tpkwdj7d574_pqq2j_dz2h0000gq/T/deno-compile-linear/src/config.ts:113:1
error: Uncaught (in promise) IsADirectory: Is a directory (os error 21): readfile '.env'
    return parse(await Deno.readTextFile(filepath));
                 ^
    at async Object.readTextFile (ext:deno_fs/30_fs.js:814:18)
    at async parseFile (https://jsr.io/@std/dotenv/0.225.6/mod.ts:244:18)
    at async load (https://jsr.io/@std/dotenv/0.225.6/mod.ts:217:26)
    at async loadEnvFiles (file:///var/folders/2b/8_tpkwdj7d574_pqq2j_dz2h0000gq/T/deno-compile-linear/src/config.ts:80:15)
    at async file:///var/folders/2b/8_tpkwdj7d574_pqq2j_dz2h0000gq/T/deno-compile-linear/src/config.ts:113:1
error: Uncaught (in promise) IsADirectory: Is a directory (os error 21): readfile '.env'
    return parse(await Deno.readTextFile(filepath));
                 ^
    at async Object.readTextFile (ext:deno_fs/30_fs.js:814:18)
    at async parseFile (https://jsr.io/@std/dotenv/0.225.6/mod.ts:244:18)
    at async load (https://jsr.io/@std/dotenv/0.225.6/mod.ts:217:26)
    at async loadEnvFiles (file:///var/folders/2b/8_tpkwdj7d574_pqq2j_dz2h0000gq/T/deno-compile-linear/src/config.ts:80:15)
    at async file:///var/folders/2b/8_tpkwdj7d574_pqq2j_dz2h0000gq/T/deno-compile-linear/src/config.ts:113:1 

It's because we have a weird structure with a .env directory. We also don't
follow popular .env file conventions; they may contain some zsh syntax in them
because SWEs typically source the files in their shell instead of treating them
as a true .env.

The Linear CLI shouldn't crash on startup if an invalid .env is encountered.
Handle this reasonably but more gracefully. Note that, ultimately, the issue is
our own unusual behavior in our codebase. Being entirely silent about the issue
may hide deeper issues and also would cause the Linear CLI to diverge from
industry standards. We can't mindlessly do that and instead need to strike a
compromise.

Activity

  1. jackarch-2 commented on Aug 26, 2026

    @jackarch-2
    Author

    The issue is more specifically here:

    if (await Deno.stat(".env").catch(() => null)) {
    . If .env is a directory, we move on and try to load it.

    I think the simplest solution is fine: silently do nothing for .env directories.

  2. added 2 commits that reference this issue on Aug 31, 2026
  3. schpetbot commented on Sep 2, 2026

    @schpetbot
    Collaborator

    Shipped in v2.6.0.

    Thanks for the report — the crash and the hang are both fixed.

    • A .env that is a directory no longer crashes the CLI on startup.
    • A .env written to be sourced by a shell no longer hangs forever; a self-referential value like export PATH=$PATH:/opt/bin used to spin the dotenv expander indefinitely.
    • An unusable .env is now reported as a warning on stderr and skipped, and the repository-root .env is still consulted as a fallback.
    • An unquoted $VAR in a LINEAR_/GH_/GITHUB_ value is skipped with a warning instead of expanded — expanding an unset variable silently produced the string "undefined".
    • LINEAR_IGNORE_ENV_FILE=1 skips .env loading entirely, for repositories whose .env is not dotenv-shaped.

    Fixed by your #265 plus the follow-up in #269.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions