fix(nginx plugin): place mime.types next to nginx.conf so include resolves - #2929
Conversation
…olves
The nginx plugin created mime.types in the Virtenv directory
({{ .Virtenv }}/mime.types), but nginx.conf lives in the DevboxDir and
uses a relative "include mime.types;" directive. nginx resolves config-time
include paths relative to the config file, not the -p prefix path, so the
service failed to start with:
[emerg] open() ".../devbox.d/nginx/mime.types" failed (2: No such file
or directory) in .../devbox.d/nginx/nginx.conf
Place mime.types in the DevboxDir alongside nginx.conf (matching how
fastcgi.conf is already handled) and bump the plugin version.
Fixes #2908
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013yJQ9FtijMB9SfnTeRVC1P
There was a problem hiding this comment.
Pull request overview
This PR fixes the nginx plugin startup failure caused by include mime.types; being resolved relative to the generated nginx.conf location (in devbox.d/nginx/), while mime.types was previously created under the virtenv prefix.
Changes:
- Bump nginx plugin version from
0.0.5to0.0.6so existing environments pick up the fix. - Relocate
mime.typescreation from{{ .Virtenv }}to{{ .DevboxDir }}soinclude mime.types;resolves during config parsing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude ptal |
|
Claude finished @mikeland73's task in 42s —— View job Review: PR #2929 — fix(nginx plugin): place mime.types next to nginx.conf
Root-cause diagnosis and the However, there's a real problem with the claim that "the plugin version is bumped 0.0.5 → 0.0.6 so existing environments pick up the relocated file." I traced the file-creation gating logic in
Net effect: for a project that already has the nginx plugin installed (i.e. exactly the reporter's scenario in #2908, and anyone else who already hit this bug), Suggestion: either
Given the design intent (devbox.d files are never silently overwritten), option 1 is likely the pragmatic path — but the PR description's claim that the version bump alone fixes existing environments should be corrected, either in the PR description or in the implementation. Everything else checks out: |
|
Took a look 👀 — status summary: CI (commit
The fix is a 2-line change to Nothing outstanding to address on my end — Generated by Claude Code |
|
Good catch on the version-bump claim — I traced I've corrected the PR description rather than changing code:
I deliberately did not take option 2 (special-casing a version bump in Generated by Claude Code |
Summary
Fixes #2908.
The nginx plugin currently fails to start because it cannot find its
mime.typesfile:Root cause: PR #2844 added
include mime.types;tonginx.confand created themime.typesfile at{{ .Virtenv }}/mime.types(.devbox/virtenv/nginx/mime.types), under the assumption thatnginx -p $NGINX_PATH_PREFIXwould make the relativeincluderesolve against the prefix path. In fact nginx only uses the-pprefix for runtime paths (error_log,access_log,root, …); at configuration time, relativeincludepaths are resolved relative to thenginx.conffile itself, which devbox places in theDevboxDir(devbox.d/nginx/).Fix: Create
mime.typesin theDevboxDiralongsidenginx.conf, so the relativeinclude mime.types;resolves correctly. This mirrors how the plugin already handlesfastcgi.conf(also created inDevboxDir). The plugin version is bumped0.0.5→0.0.6to follow the existing convention (PR #2844 bumped0.0.4→0.0.5).Scope: fresh installs vs. existing environments
This fix applies automatically to fresh installs of the nginx plugin (new projects, or projects with no prior nginx lockfile entry) — the relocated
mime.typesis created next tonginx.confand theincluderesolves.It does not auto-remediate environments that already installed the plugin (i.e. anyone already affected by #2908). Devbox intentionally treats files under
devbox.d/as user-owned and never overwrites them once the plugin is recorded indevbox.lock:shouldCreateFile(internal/plugin/plugin.go:233) returnsfalsefor anydevbox.d/path whenPluginVersion != "", and this check is not gated on a version change — so the version bump alone does not force regeneration. (The same limitation applied to PR #2844's original change.)Manual remediation for existing broken environments: remove the plugin's materialized config dir and reinstall, e.g.
The stale
.devbox/virtenv/nginx/mime.typesfrom0.0.5is harmless — nothing references it after this change.How was it tested?
plugins/nginx.jsonremains valid JSON.nginx.confis created at{{ .DevboxDir }}/nginx.confand uses a relativeinclude mime.types;; placingmime.typesin the sameDevboxDirmakes the include resolvable. Thefastcgi.conffile already follows this exact placement pattern.CreateFilesForConfig/shouldCreateFileininternal/plugin/plugin.goto confirm fresh installs create the file (alldevbox.d/nginx/files are only created because a fresh install has no lockedPluginVersion) and to characterize the existing-environment behavior documented above.{{ .Virtenv }}/mime.typespath exist in the codebase, and the nginxenv.test.txttestscript does not assert on themime.typeslocation, so behavior is unchanged apart from the fix.cc @jefft (issue reporter)
Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
🤖 Generated with Claude Code
https://claude.ai/code/session_013yJQ9FtijMB9SfnTeRVC1P