Repository navigation
Confusion when using a configuration file in a different directory #4264
Deployer Versionv8.0.5 Target OSMacOS 14.8.9 Which PHP version are you using?PHP 8.5 Content of deploy.php or deploy.yamlSteps to reproduceWhen running the following command...
Deployer creates two deployment directories and does not use either one consistently. Note: the Magento 2 recipe is used. The intent is to test the deployment locally.
Output:
|
Replies: 3 comments
|
The problem is the relative paths. Most deploy tasks start with
Use absolute paths and build For |
|
Thanks! An absolute path did indeed fix the issue. Behavior becomes the same regardless of where the configuration file is located. I'll note that an absolute path does not meet my requirements. I'm attempting to create a configuration that would test the deployment locally across a team of people with different operating systems. Can't guarantee any absolute path would be present on multiple local systems. Only guarantee is what's checked out of the repository that the configuration file is in. But, I suppose compatibility with relative paths is a messy business :P |
|
An absolute path can be derived from each checkout, so teammates do not need the same host directory. Put this beside your existing <?php
namespace Deployer;
set('checkout_root', dirname(__DIR__));
import(__DIR__ . '/deploy.maml');Then merge these fields into the existing local Keep its other fields, the Magento recipe import, and your existing tasks and hooks. From the checkout root, use Example and checks: the Magento recipe is used only for path inspection; a separate common-recipe fixture exercises inert artifact publication and checkout relocation. The check passed with Deployer 8.0.5 and PHP 8.3.6 on Ubuntu 24.04: unchanged configuration survived physical relocation, and the common-recipe fixture published two artifacts while preserving the earlier release. This checks the local-path pattern, not your Magento application or Docker/cron hooks; macOS/PHP 8.5 and other operating systems were not tested. |

The problem is the relative paths.
deploy_path: "testdeploy"andcurrent_path: "public_html"get resolved against whatever directory the command happens to be running in, and that changes during the deploy.Most deploy tasks start with
cd('{{deploy_path}}'). You can see it break indeploy:release: it has already cd'ed intotestdeploy, and then runstestdeploy/releaserelative totestdeploy/istestdeploy/testdeploy/release, which doesn't exist, henceln: testdeploy/release: No such file or directory. Tasks that don't cd first resolve the same values from the project root instead, so one setting points at two different places depending on the task.