Skip to content

fix(plugins): quote path env vars in service commands so spaces in project dir work - #2960

Open
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-vspngu
Open

fix(plugins): quote path env vars in service commands so spaces in project dir work#2960
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-vspngu

Conversation

@mikeland73

Copy link
Copy Markdown
Contributor

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.:

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.

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 by Claude Code

…oject dir work

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 |
| 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 |

These variables/templates expand to the project's absolute path (for
example $CADDY_CONFIG -> "{{ .DevboxDir }}/Caddyfile"), so an unquoted
reference is word-split by the shell whenever the project directory
contains a space and the service fails to start. This is the same class
of bug as the init_hook fix in #2876, now applied to service commands.

Wrap each path reference in double quotes, matching the pattern the
postgresql plugin already uses (`-k "$PGHOST"`). Ports and other
non-path values are left unquoted. The affected plugins' version fields
are bumped, consistent with how prior plugin behavior changes are
versioned.

Adds 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 fails on the old
(unquoted) content and passes on the fix.

Fixes #2631
Copilot AI lite review requested due to automatic review settings August 18, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Workspaces with blanks in pathnames are not properly handled

3 participants