{{ message }}
Repository navigation
fix(plugins): quote templated hook paths so spaces in project dir work - #2876
Merged
Merged
Conversation
The python, poetry, mariadb and mysql builtin plugins referenced a
templated absolute path (e.g. "{{ .Virtenv }}/bin/venvShellHook.sh") in
their init_hook without wrapping it in double quotes. Because .Virtenv
expands to the project's absolute path, an unquoted reference is word-split
by the shell whenever the project directory contains a space, so the hook
fails to run:
bash: /home/me/Documents/rm: No such file or directory
Wrap each templated path in double quotes (matching the existing nodejs
plugin), and bump the affected plugins' versions. Adds a regression test
that asserts no builtin plugin's init_hook contains an unquoted templated
path.
Fixes #2673
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes devbox shell failures when the project directory contains spaces by ensuring builtin plugin shell.init_hook commands properly quote templated absolute paths (e.g. {{ .Virtenv }}), preventing shell word-splitting.
Changes:
- Quote templated
{{ .Virtenv }}paths ininit_hookfor thepython,poetry,mysql, andmariadbplugins. - Bump the affected plugin versions from
0.0.4to0.0.5. - Add a Go regression test to enforce quoting for templated values in builtin plugin
init_hooklines.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| plugins/python.json | Quotes the templated virtenv hook script path and bumps plugin version. |
| plugins/poetry.json | Quotes the templated init hook script path and bumps plugin version. |
| plugins/mysql.json | Quotes the templated setup_db.sh path in the bash invocation and bumps plugin version. |
| plugins/mariadb.json | Quotes the templated setup_db.sh path in the bash invocation and bumps plugin version. |
| plugins/init_hook_quoting_test.go | Adds a regression test to enforce quoting of templated init_hook content across builtin plugins. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review feedback on the init_hook quoting regression test. The previous insideDoubleQuotes helper only toggled on " and could produce false negatives: a literal double quote inside a single-quoted segment would flip the state, and an unterminated quote was treated as quoted. Replace it with shellQuotedPositions, which models the parts of POSIX shell quoting relevant to word-splitting: single and double quotes are mutually exclusive, a backslash escapes a double quote inside double quotes, and a quote that is never closed leaves its bytes unquoted (so an unterminated segment is reported as unsafe).
golangci-lint's varnamelen flagged the single-letter byte variable used across the quote-scanning loop (distance exceeds max-distance: 10). Use a descriptive name instead.
The project-tests-only job failed only on the elixir example (mix deps.get / mix run), which is unrelated to this PR's plugin init_hook quoting change. Re-running to clear the flaky failure.
Collaborator
Author
mikeland73
added a commit
that referenced
this pull request
Sep 14, 2026
…oject dir work (#2960) ## Summary Fixes #2631. Several builtin plugins reference an absolute project path in their process-compose **service command** without wrapping it in double quotes: | Plugin | command (before) | | --- | --- | | `apache` | `apachectl start -f $HTTPD_CONFDIR/httpd.conf ...`, `tail -f $HTTPD_ERROR_LOG_FILE`, `tail -f $HTTPD_ACCESS_LOG_FILE` | | `caddy` | `caddy run --config=$CADDY_CONFIG` | | `php` | `php-fpm -y {{ .DevboxDir }}/php-fpm.conf --nodaemonize` | | `redis` | `redis-server $REDIS_CONF --port $REDIS_PORT` | | `valkey` | `valkey-server $VALKEY_CONF --port $VALKEY_PORT` | Each of these variables/templates expands to the project's **absolute path** (for example `$CADDY_CONFIG` → `{{ .DevboxDir }}/Caddyfile`, `$REDIS_CONF` → `{{ .DevboxDir }}/redis.conf`). An unquoted reference is word-split by the shell whenever the project directory contains a space, so the service fails to start. This is the same class of bug as the `init_hook` fix in #2876 — now applied to the plugin **service commands** that run under `devbox services`. ### Fix Wrap each path reference in double quotes, matching the pattern the `postgresql` plugin already uses (`pg_isready -p "${PGPORT:-5432}"` and `-k "$PGHOST"`). Ports and other non-path values are left unquoted. After the fix, e.g.: ```yaml command: "caddy run --config=\"$CADDY_CONFIG\"" command: "php-fpm -y \"{{ .DevboxDir }}/php-fpm.conf\" --nodaemonize" ``` The affected plugins' `version` fields are bumped, consistent with how prior plugin behavior changes are versioned. The `mariadb`, `mysql`, and `nginx` plugins have the same unquoted-path pattern in their service commands, but they currently have other in-flight PRs touching those exact files (#2906, #2911, #2909). They were intentionally left out of this PR to avoid conflicts and can be quoted in those PRs or a small follow-up. ## How was it tested? - Added `plugins/service_command_quoting_test.go`, which scans every builtin plugin's `process-compose.yaml` and asserts that templated paths (`{{ ... }}`) and known path-bearing env vars in service commands are quoted. It reuses the shell-quoting model from the existing `init_hook_quoting_test.go`. Verified it **fails** on the old (unquoted) content and **passes** on the fix. - `go test ./plugins/ ./internal/plugin/`, `go vet ./plugins/`, and `gofmt` are clean. cc @arent-groebner — thanks for the report. ## Community Contribution License All community contributions in this pull request are licensed to the project maintainers under the terms of the [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0). 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](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license). --- _Generated by [Claude Code](https://claude.ai/code/session_017vU39wucKJwc6SGydhzoiN)_ Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #2673.
Several builtin plugins reference a templated absolute path in their
init_hookwithout wrapping it in double quotes:init_hookline (before)python{{ .Virtenv }}/bin/venvShellHook.shpoetry{{ .Virtenv }}/bin/initHook.shmariadbbash {{ .Virtenv }}/setup_db.shmysqlbash {{ .Virtenv }}/setup_db.shBecause
{{ .Virtenv }}expands to the project's absolute path, an unquoted reference is word-split by the shell whenever the project directory contains a space. The hook then fails to run and the shell startup breaks:Fix
Wrap each templated path in double quotes, matching the pattern the
nodejsplugin already uses (node "{{ .Virtenv }}/bin/setup-corepack.js"). After rendering, the generated hook becomes a single quoted token, e.g.:"/home/me/Documents/rm scripts/.devbox/virtenv/python/bin/venvShellHook.sh"The affected plugins'
versionfields are bumped (0.0.4→0.0.5), consistent with how prior plugin behavior changes are versioned.The hook scripts themselves (
venvShellHook.sh,initHook.sh,setup_db.sh) already quote their internal path variables, so the only gap was the invocation line.Testing
plugins/init_hook_quoting_test.go, which scans every builtin plugin and asserts that any{{ ... }}template used in aninit_hookline is enclosed in double quotes. It fails on the old (unquoted) content and passes on the fix.bash -nsyntax-checked each rendered line.go test ./plugins/ ./internal/plugin/,go vet, andgofmtare clean.cc @xorinzor (issue reporter) — thanks for the clear reproduction and root-cause.
Generated by Claude Code