Skip to content

fix(cli): load the default .env when DOTENV_PATH is empty - #1076

Merged
motdotla merged 1 commit into
motdotla:masterfrom
Enesuygurs:fix/cli-empty-dotenv-path
Oct 22, 2026
Merged

motdotla merged 1 commit into
motdotla:masterfrom
Enesuygurs:fix/cli-empty-dotenv-path

Conversation

@Enesuygurs

Copy link
Copy Markdown
Contributor

Summary

dotenv run treats an empty DOTENV_PATH (or legacy DOTENV_CONFIG_PATH) as an explicit path. '' resolves to the current directory, so reading it fails and the command never runs:

$ DOTENV_PATH= dotenv run node -e "console.log(process.env.BASIC)"
dotenv: EISDIR: illegal operation on a directory, read

config() already treats an empty path as unset and loads the default .env. The CLI does the same for an empty DOTENV_ENCODING. Empty values are common when a variable is forwarded but never set, e.g. DOTENV_PATH=${DOTENV_PATH} in Docker Compose or CI.

With this change the CLI only uses the environment path when it is non-empty. Otherwise it keeps the default .env, including the allowance for that file being missing. An empty DOTENV_PATH still does not fall back to DOTENV_CONFIG_PATH.

Tests

  • Added a CLI regression test for empty DOTENV_PATH and DOTENV_CONFIG_PATH. It fails with EISDIR before the fix.
  • npm test (build, standard, TypeScript check): 1,408 passing assertions and 1 platform skip, on Node 26 / Windows.
  • npm run test:perf: passes the 1.5x gate.

@motdotla

Copy link
Copy Markdown
Owner

good catch here

@motdotla
motdotla merged commit 88228bd into motdotla:master Oct 22, 2026
13 of 16 checks passed
@motdotla

Copy link
Copy Markdown
Owner

going out as 18.0.9 now. thanks!

renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 24, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 18.0.7 | 18.0.9 |


## [v18.0.9](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#1076](motdotla/dotenv#1076))


## [v18.0.8](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

##### Changed

- Fast parser should strip appended extra quotes ([#1073](motdotla/dotenv#1073))
- Type detail improvement ([#1074](motdotla/dotenv#1074))
markharding pushed a commit to futo-org/Harbor that referenced this pull request Oct 27, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | [`18.0.7` → `18.0.9`](https://renovatebot.com/diffs/npm/dotenv/18.0.7/18.0.9) | ![age](https://developer.mend.io/api/mc/badges/age/npm/dotenv/18.0.9?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/dotenv/18.0.7/18.0.9?slim=true) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/99) for more information.

---

### Release Notes

<details>
<summary>motdotla/dotenv (dotenv)</summary>

### [`v18.0.9`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

[Compare Source](motdotla/dotenv@v18.0.8...v18.0.9)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#&#8203;1076](motdotla/dotenv#1076))

### [`v18.0.8`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

[Compare Source](motdotla/dotenv@v18.0.7...v18.0.8)

##### Changed

- Fast parser should strip appended extra quotes ([#&#8203;1073](motdotla/dotenv#1073))
- Type detail improvement ([#&#8203;1074](motdotla/dotenv#1074))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 9am on tuesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNzUuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE3NS4xIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

Reviewed-on: https://code.futo.org/harbor/harbor/pulls/2032
markharding pushed a commit to futo-org/Harbor that referenced this pull request Oct 29, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | [`18.0.7` → `18.0.9`](https://renovatebot.com/diffs/npm/dotenv/18.0.7/18.0.9) | ![age](https://developer.mend.io/api/mc/badges/age/npm/dotenv/18.0.9?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/dotenv/18.0.7/18.0.9?slim=true) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/99) for more information.

---

### Release Notes

<details>
<summary>motdotla/dotenv (dotenv)</summary>

### [`v18.0.9`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

[Compare Source](motdotla/dotenv@v18.0.8...v18.0.9)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#&#8203;1076](motdotla/dotenv#1076))

### [`v18.0.8`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

[Compare Source](motdotla/dotenv@v18.0.7...v18.0.8)

##### Changed

- Fast parser should strip appended extra quotes ([#&#8203;1073](motdotla/dotenv#1073))
- Type detail improvement ([#&#8203;1074](motdotla/dotenv#1074))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 9am on tuesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNzUuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE3NS4xIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

Reviewed-on: https://code.futo.org/harbor/harbor/pulls/2032
OIRNOIR pushed a commit to OIRNOIR/YouTube-Helper-Server that referenced this pull request Oct 29, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | imports | patch | [`18.0.8` -> `18.0.9`](https://renovatebot.com/diffs/npm/dotenv/18.0.8/18.0.9) |

---

### Release Notes

<details>
<summary>motdotla/dotenv (dotenv)</summary>

### [`v18.0.9`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

[Compare Source](motdotla/dotenv@v18.0.8...v18.0.9)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#&#8203;1076](motdotla/dotenv#1076))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODIuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE4Mi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Server/pulls/65
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 30, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 18.0.7 | 18.0.9 |


## [v18.0.9](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#1076](motdotla/dotenv#1076))


## [v18.0.8](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

##### Changed

- Fast parser should strip appended extra quotes ([#1073](motdotla/dotenv#1073))
- Type detail improvement ([#1074](motdotla/dotenv#1074))
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Nov 1, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 18.0.7 | 18.0.9 |


## [v18.0.9](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#1076](motdotla/dotenv#1076))


## [v18.0.8](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

##### Changed

- Fast parser should strip appended extra quotes ([#1073](motdotla/dotenv#1073))
- Type detail improvement ([#1074](motdotla/dotenv#1074))
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Nov 4, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 18.0.7 | 18.0.9 |


## [v18.0.9](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1809-2026-10-14)

##### Changed

- Permit DOTENV_PATH being empty string with the CLI ([#1076](motdotla/dotenv#1076))


## [v18.0.8](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1808-2026-10-14)

##### Changed

- Fast parser should strip appended extra quotes ([#1073](motdotla/dotenv#1073))
- Type detail improvement ([#1074](motdotla/dotenv#1074))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants