-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I repeatedly encountered this error while running provision with deployer v7.4.0 on a clean Ubuntu 20.04 installation
> task provision:website
[beta.midhun.ca] ErrorException in website.php on line 26:
[beta.midhun.ca]
[beta.midhun.ca] file_get_contents(./Caddyfile): Failed to open stream: No such file or directory
[beta.midhun.ca]
ERROR: Task provision:website failed!
I managed to fix it by:
- Adding
_DIR_to file reference resulting infile_get_contents(__DIR__ . '/Caddyfile') - Adding
Caddyfileto the build
echo "Add file: /Caddyfile\n";
$phar->addFile(realpath(__DIR__ . '/../recipe/provision/Caddyfile'), '/recipe/provision/Caddyfile');Then i encountered another error:
> task provision:website
[beta.midhun.ca] error in website.php on line 17:
[beta.midhun.ca] run realpath /var/www/somehostname
[beta.midhun.ca] err realpath: /var/www/somehostname: No such file or directory
[beta.midhun.ca] exit code 1 (General error)
ERROR: Task provision:website failed!
This is where the error happened:
set('deploy_path', run("realpath {{deploy_path}}"));
run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}");
run("chown -R deployer:deployer {{deploy_path}}");Upon further testing, this happens when /var/www directory is not present.
So if the parent directory of the deploy_path is absent, this error occurs.
I moved set('deploy_path', run("realpath {{deploy_path}}")); after run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); to make sure realpath runs after creating the directory
It seems like code sequence got mixed up when looking at the source provision:website in recipe/provision/website.php.
These fixes the issues i had. I'm working on a PR.
Discussed in #3821
Originally posted by mariomka April 23, 2024
- Deployer version: 7.4.0
- Deployment OS: Ubuntu 20.04
I'm trying to provision a clean server in Hetzner Cloud (CCX13 - dedicated 2 vCPU 8GB RAM) with the Laravel recipe. I got an error; I tried several times with different PHP versions and removed and created the server.
The error is the following:
[servername] ErrorException in website.php on line 24:
[servername]
[servername] file_get_contents(./Caddyfile): Failed to open stream: No such file or directory
[servername]
ERROR: Task provision:website failed!
The deploy.yaml file:
import:
- recipe/laravel.php
config:
repository: 'git@github.com:XXX/xxx'
hosts:
servername:
remote_user: deployer
deploy_path: '/var/www/my-project'
tasks:
build:
- run: uptime
after:
deploy:failed: deploy:unlock
```</div>