From ee0e79dd4de3c11d407333f6118e9fd8ec8feed5 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 5 Mar 2026 15:33:58 -0600 Subject: [PATCH 1/3] fix: pre-create xdebug.log with world-writable permissions When xdebug is enabled, the log file at /tmp/xdebug.log can be created as root during build_as_root or run_as_root steps. Subsequent runs as www-data then fail because the file is owned by root. Pre-create the log file with 666 permissions during the same build_as_root_internal step that enables xdebug, ensuring any user can write to it regardless of which user triggers the first write. --- builders/php.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builders/php.js b/builders/php.js index 8a63dfc..df41f6f 100644 --- a/builders/php.js +++ b/builders/php.js @@ -250,7 +250,10 @@ module.exports = { // Add build step to enable xdebug if (options.xdebug) { - addBuildStep(['docker-php-ext-enable xdebug'], options._app, options.name, 'build_as_root_internal'); + addBuildStep([ + 'docker-php-ext-enable xdebug', + 'touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log', + ], options._app, options.name, 'build_as_root_internal'); } // Add build step to install our Composer global packages From b9f6708997089088bd3b8d0f00050ad8edfed3c4 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 5 Mar 2026 15:34:36 -0600 Subject: [PATCH 2/3] docs: add changelog entry for xdebug log fix --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb52f33..ceb3d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed xdebug log file ownership issue when `build_as_root` or `run_as_root` creates `/tmp/xdebug.log` as root [#242](https://github.com/lando/php/pull/242) + ## v1.11.2 - [February 25, 2026](https://github.com/lando/php/releases/tag/v1.11.2) * Fixed composer install crash caused by legacy prestissimo removal running as wrong user From 9c7df60538b139375753f822e0247e681882d766 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 5 Mar 2026 15:37:04 -0600 Subject: [PATCH 3/3] fix: pre-create xdebug log unconditionally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the touch/chmod of /tmp/xdebug.log outside the xdebug conditional so it runs for all PHP services regardless of xdebug config. This is defensive — ensures the file is always writable even if xdebug gets enabled later or something else writes to that path. --- builders/php.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builders/php.js b/builders/php.js index df41f6f..5745f1b 100644 --- a/builders/php.js +++ b/builders/php.js @@ -248,12 +248,13 @@ module.exports = { options.composer_version = options.composer_version.toString(); } + // Pre-create xdebug log with world-writable permissions so root-owned builds + // don't block www-data from writing to it later + addBuildStep(['touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log'], options._app, options.name, 'build_as_root_internal'); + // Add build step to enable xdebug if (options.xdebug) { - addBuildStep([ - 'docker-php-ext-enable xdebug', - 'touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log', - ], options._app, options.name, 'build_as_root_internal'); + addBuildStep(['docker-php-ext-enable xdebug'], options._app, options.name, 'build_as_root_internal'); } // Add build step to install our Composer global packages