fix(nginx plugin): place mime.types next to nginx.conf so include resolves#2918
fix(nginx plugin): place mime.types next to nginx.conf so include resolves#2918mikeland73 wants to merge 2 commits into
Conversation
…olves
nginx resolves include directives relative to the config file's directory,
not the -p prefix path. The mime.types file was created in the virtenv
($NGINX_PATH_PREFIX) while nginx.conf lives in the devbox.d dir, so
`include mime.types;` failed with 'No such file or directory' and the
service could not start.
Move the create_files destination for mime.types from {{ .Virtenv }} to
{{ .DevboxDir }} so it sits alongside nginx.conf, and add the file to the
nginx example project. Bump the plugin version to 0.0.6.
Fixes #2908
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uK5pHhERaRaoDAvNdw9ww
There was a problem hiding this comment.
Pull request overview
This PR fixes the nginx plugin failing to start due to include mime.types; resolving relative to nginx.conf’s directory (devbox.d/nginx/) rather than the -p prefix (.devbox/virtenv/nginx/). It relocates where the plugin scaffolds mime.types so the include can resolve correctly, and updates the nginx example accordingly.
Changes:
- Bump nginx plugin version to
0.0.6. - Generate
mime.typesintodevbox.d/nginx/(next tonginx.conf) instead of the virtenv. - Add
mime.typesto the checked-in nginx server example so it works out of the box.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| plugins/nginx.json | Moves mime.types creation to {{ .DevboxDir }} and bumps plugin version to match the fix. |
| examples/servers/nginx/devbox.d/nginx/mime.types | Adds the mime.types file to the nginx example so include mime.types; resolves correctly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "{{ .Virtenv }}/temp": "", | ||
| "{{ .Virtenv }}/mime.types": "nginx/mime.types", | ||
| "{{ .DevboxDir }}/mime.types": "nginx/mime.types", | ||
| "{{ .Virtenv }}/process-compose.yaml": "nginx/process-compose.yaml", |
There was a problem hiding this comment.
Good catch — confirmed against internal/plugin/plugin.go:241-243: shouldCreateFile() returns false for any devbox.d/ path once the plugin is installed (PluginVersion != ""), and the version bump doesn't reset that (it's a non-empty check, not a version comparison). So placing mime.types in {{ .DevboxDir }} would leave existing installs broken.
I've switched to your option (b): mime.types stays in the virtenv ({{ .Virtenv }}, under .devbox, always regenerated), and process-compose.yaml — also regenerated under .devbox — now copies it into $NGINX_CONFDIR next to nginx.conf at service start when missing:
if [ ! -f $NGINX_CONFDIR/mime.types ] && [ -f $NGINX_PATH_PREFIX/mime.types ]; then cp $NGINX_PATH_PREFIX/mime.types $NGINX_CONFDIR/mime.types; fiThis remediates both fresh and already-installed projects. Pushed in b39af3a.
Generated by Claude Code
Keep mime.types in the virtenv (which lives under .devbox and is always
regenerated) and copy it into $NGINX_CONFDIR at service startup when
missing, instead of relying on create_files to place it in devbox.d.
Manager.shouldCreateFile() skips creating any devbox.d file once a plugin
is installed (PluginVersion set in devbox.lock), so placing mime.types in
{{ .DevboxDir }} would not remediate existing nginx installs. Doing the
copy from process-compose.yaml — also regenerated under .devbox — fixes
both fresh and already-installed projects.
Addresses review feedback on #2908.
Summary
Fixes #2908.
The nginx plugin's service fails to start because it can't find
mime.types:PR #2844 added
include mime.types;to nginx.conf and created themime.typesfile under{{ .Virtenv }}(.devbox/virtenv/nginx/), on the assumption thatnginx -p $NGINX_PATH_PREFIXwould make theincluderesolve relative to the prefix. As the reporter (@jefft) correctly diagnosed, nginx only uses the-pprefix for runtime paths (error_log,access_log,root, …). At configuration time, relative paths inincludeare resolved relative to the directory ofnginx.confitself — which is{{ .DevboxDir }}(devbox.d/nginx/), not the virtenv. So the include pointed at a file that wasn't there.Fix
mime.typesneeds to sit next tonginx.confin$NGINX_CONFDIR. Simply moving thecreate_filesdestination to{{ .DevboxDir }}would fix fresh installs but not existing ones:Manager.shouldCreateFile()(internal/plugin/plugin.go:241-243) skips creating anydevbox.d/file once a plugin is installed (PluginVersionset indevbox.lock), even when the file is missing, and the version bump doesn't reset that.Instead, this PR does the copy at service-startup time from files that always live under
.devbox(which is regenerated on every env compute):mime.typescontinues to be created in the virtenv ({{ .Virtenv }}/mime.types), which is always regenerated.plugins/nginx/process-compose.yaml— also regenerated under.devbox— copiesmime.typesinto$NGINX_CONFDIRnext tonginx.confwhen it's missing, before starting nginx:mime.typesfile to the checked-in nginx server example so it works out of the box.0.0.5→0.0.6.This remediates both fresh installs and projects that already have nginx installed.
How was it tested?
Reproduced the failure and verified the fix by following the issue's repro steps:
With the change,
mime.typesis copied todevbox.d/nginx/mime.typesnext tonginx.confat service start, theincluderesolves, and the service starts cleanly. The change is limited to plugin data files (JSON config, process-compose YAML, and a staticmime.types); no Go code paths are affected./cc @jefft (issue reporter) — thanks for the precise diagnosis.
Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
🤖 Generated with Claude Code
https://claude.ai/code/session_017uK5pHhERaRaoDAvNdw9ww