# Deploy fails at 'Wordpress Installed?'

**URL:** https://discourse.roots.io/t/deploy-fails-at-wordpress-installed/20888
**Category:** trellis
**Tags:** trellis-cli
**Created:** 2021-06-04T13:31:51Z
**Posts:** 24

## Post 1 by @James_Cobbett — 2021-06-04T13:31:51Z

My deploy has just started failing to my production server, but still works fine on staging. This is the error message i’m getting:

```
TASK [deploy : WordPress Installed?] *************************************************************************************************************
System info:
  Ansible 2.9.6; Darwin
  Trellis version (per changelog): "Improve handling of PHP versions and support PHP 8.0"
---------------------------------------------------
non-zero return code
fatal: [178.62.58.180]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/squaremilechurches.com/shared/tmp_multisite_constants.php"], "delta": "0:00:00.243627", "end": "2021-06-04 13:28:00.113050", "failed_when_result": true, "rc": 255, "start": "2021-06-04 13:27:59.869423", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

PLAY RECAP ***************************************************************************************************************************************
178.62.58.180 : ok=25 changed=9 unreachable=0 failed=1 skipped=33 rescued=0 ignored=0   
localhost : ok=0 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
```

It seemed to coincide with setting up wp-rocket, but that might just be a coincidence because it’s working on staging, and i’ve removed the stuff added for wp-rocket and it’s still doing this.

I was able to deploy fine this morning.

Any help appreciated!

---

## Post 2 by @alwaysblank — 2021-06-04T14:20:46Z

Can you ssh into your server and run the wp cli command?

Running the trellis command with verbose output might also show you more information.

---

## Post 3 by @James_Cobbett — 2021-06-04T14:48:10Z

Thanks for the reply. I can ssh into the server, but not sure what command I should run?

---

## Post 4 by @strarsis — 2021-06-04T15:15:57Z

Also, have you provisioned the server (don’t confuse with deploying a site!)?  
Adding or modifying sites requires a (re-)provisioning of the server (ansible-playbook run).

---

## Post 5 by @James_Cobbett — 2021-06-04T15:20:41Z

Yep, i’ve provisioned it, and deployed to it several times previously. The site is live.

I’ve also re-provisioned both staging and production, deploys to staging work but not production.

---

## Post 6 by @strarsis — 2021-06-04T15:25:54Z

The failing command is logged by ansible:

```
["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/squaremilechurches.com/shared/tmp_multisite_constants.php"]
```

Which would be this raw

```
wp core is-installed --skip-plugins --skip-themes --require=/srv/www/squaremilechurches.com/shared/tmp_multisite_constants.php
```

Invoke this command directly on the production server, in the site directory (`/srv/www/squaremilechurches.com/current`).  
What error do you get?

Also you could try to run the deploy command with debug flag (but this can be overwhelming).

---

## Post 7 by @James_Cobbett — 2021-06-04T15:37:26Z

Thanks for that, I get no error running that via ssh. It seemingly runs with no output.

If I try and deploy in verbose mode this is my error:  
non-zero return code  
fatal: [178.62.58.180]: FAILED! =\> {  
“changed”: false,  
“cmd”: [  
“wp”,  
“core”,  
“is-installed”,  
“–skip-plugins”,  
“–skip-themes”,  
“–require=/srv/www/squaremilechurches.com/shared/tmp\_multisite\_constants.php”  
],  
“delta”: “0:00:00.259695”,  
“end”: “2021-06-04 15:36:34.329746”,  
“failed\_when\_result”: true,  
“invocation”: {  
“module\_args”: {  
“\_raw\_params”: “wp core is-installed --skip-plugins --skip-themes --require=/srv/www/squaremilechurches.com/shared/tmp\_multisite\_constants.php”,  
“\_uses\_shell”: false,  
“argv”: null,  
“chdir”: “/srv/www/squaremilechurches.com/releases/20210604153609”,  
“creates”: null,  
“executable”: null,  
“removes”: null,  
“stdin”: null,  
“stdin\_add\_newline”: true,  
“strip\_empty\_ends”: true,  
“warn”: true  
}  
},  
“rc”: 255,  
“start”: “2021-06-04 15:36:34.070051”,  
“stderr”: “”,  
“stderr\_lines”: [],  
“stdout”: “”,  
“stdout\_lines”: []  
}

---

## Post 8 by @strarsis — 2021-06-04T16:33:58Z

Right, `is-installed` will terminate itself with an exit code that indicates whether it is installed or not.  
Invoke that composer command, then use `echo $?` to print the exit code.

---

## Post 9 by @James_Cobbett — 2021-06-04T16:38:46Z

Have just done that:  
**web@squaremile** : **/srv/www/squaremilechurches.com/current** $ wp core is-installed  
**web@squaremile** : **/srv/www/squaremilechurches.com/current** $ echo $?  
0

---

## Post 10 by @strarsis — 2021-06-04T16:40:53Z

Alright, during deploy the `current` symlink is changed.  
Try the composer command again in directory `/srv/www/squaremilechurches.com/releases/20210604153609`.

The symptoms indicate that WordPress core (roots wordpress package) wasn’t installed by composer, hence the CLI doesn’t deem the core to be installed.

---

## Post 11 by @James_Cobbett — 2021-06-04T16:44:18Z

Interesting, now I get an error code:  
**web@squaremile** : **/srv/www/squaremilechurches.com/releases/20210604153609** $ wp core is-installed --skip-plugins --skip-themes --require=/srv/www/squaremilechurches.com/shared/tmp\_multisite\_constants.php

**web@squaremile** : **/srv/www/squaremilechurches.com/releases/20210604153609** $ echo $?

255

Wordpress core must have been installed by composer though, because I provisioned the server when I created it. Any ideas on how to fix this?

---

## Post 12 by @strarsis — 2021-06-04T16:48:17Z

Provisioning the server doesn’t install composer core for the sites, this happens during deploy for a particular site.

Inside the directory `/srv/www/squaremilechurches.com/releases/20210604153609`, run `composer install`. Does it work, any errors or warnings?

---

## Post 13 by @James_Cobbett — 2021-06-04T16:51:57Z

Ahh yeah of course it does.

composer install worked without any errors.

---

## Post 14 by @strarsis — 2021-06-04T16:53:22Z

But `wp core is-installed --skip-plugins --skip-themes --require=/srv/www/squaremilechurches.com/shared/tmp_multisite_constants.php` will still have a non-0 (e.g. 255) exit code?

---

## Post 15 by @James_Cobbett — 2021-06-04T16:54:49Z

Yep, still got error 255.

When I ran composer install it didn’t install WP, presumably because it is already installed… Is it worth me trying to to downgrade WP which might force it to install it again?

---

## Post 16 by @strarsis — 2021-06-04T16:56:16Z

You can also remove (better rename it!) the `web/wp` folder from that particular release and re-run `composer install`. This is where there WordPress core files are.

---

## Post 17 by @James_Cobbett — 2021-06-04T17:12:45Z

Downgrading WP to force install didn’t fix it.

I tried renaming the wp folder to wp2 and then running composer install. It installed WP again, but then still returned a 255 message:  
**web@squaremile** : **/srv/www/squaremilechurches.com/releases/20210604153609** $ composer install

Installing dependencies from lock file (including require-dev)

Verifying lock file contents can be installed on current platform.

Package operations: 1 install, 0 updates, 0 removals

- Installing roots/wordpress (5.7.2): Extracting archive

Package asm89/twig-cache-extension is abandoned, you should avoid using it. Use twig/cache-extension instead.

Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.

Package http-interop/http-server-middleware is abandoned, you should avoid using it. Use psr/http-server-middleware instead.

Generating optimized autoload files

28 packages you are using are looking for funding.

Use the `composer fund` command to find out more!

Dumping package paths

82 package paths dumped

**web@squaremile** : **/srv/www/squaremilechurches.com/releases/20210604153609** $ wp core is-installed --skip-plugins --skip-themes --require=/srv/www/squaremilechurches.com/shared/tmp\_multisite\_constants.php

**web@squaremile** : **/srv/www/squaremilechurches.com/releases/20210604153609** $ echo $?

255

Could wp-cli be looking in the wrong place for WP?

---

## Post 18 by @strarsis — 2021-06-04T17:15:41Z

The `.env` file in the release directory is critical for paths, secrets and database configuration.

This seems to be very relevant:

> <https://github.com/wp-cli/core-command/issues/123>
>
> Bug Report
> Yes, I reviewed the contribution guidelines.
> Yes, more specifically, I reviewed the guidelines on how to write clear bug...

  

> <https://wordpress.stackexchange.com/questions/338249/wp-cli-silently-fails-with-255-when-running-wp-core-install>

  
The SO discussion is interesting as the underlying reason was in that case missing, required PHP extensions.

The expected exit codes for `is-installed` are `0` and `1`, `255` is not stated in the documentation:

> **[wp core is-installed | WP-CLI Command | WordPress Developer Resources](https://developer.wordpress.org/cli/commands/core/is-installed/#examples)**
>
> Determines whether WordPress is installed by checking if the standard database tables are installed. Doesn't produce output; uses exit codes…

---

## Post 19 by @James_Cobbett — 2021-06-04T17:51:03Z

I’ve figured what caused it to break - although no idea why it only affected staging and production. When I added wp-rocket I added two new env variables in /all/vault.yml. When it broke I removed all the other wp-rocket changes I made, but forgot about the env variables, i’ve just removed these and now it deploys again.

I’ve no idea why it broke the deploy - i’ve added those variables to other projects with no problems. I’ve also no idea why it only broke production…

At least I was able to get my release deployed now, i’ll try adding the variables again next week.

Thanks for your help. I’ll post back when I try to set the .env variables again next week, i’ll either need more help, or this might prove useful for someone else one day.

---

## Post 20 by @alwaysblank — 2021-06-04T17:56:00Z

When I’m working with YAML files I find it’s useful to turn on “show invisible characters” (or whatever the IDE-appropriate setting is). YAML will sometimes produce bizarre results because you, say, used a tab instead of spaces–which you’ll never catch unless you look at what the exact characters are. Running YAML files through a validator can also be helpful.

---

## Post 21 by @James_Cobbett — 2021-06-04T17:58:42Z

Thanks, that’s a good tip. I copied these directly from another YAML file, it’s pretty plausible I used a tab to format them so maybe that was all it was.

---

## Post 22 by @strarsis — 2021-06-04T18:15:46Z

Also check the PHP/error logs for plugin related errors. When the plugin needs such environment variables and they aren’t set properly, the plugin may cause a fatal PHP error.

---

## Post 23 by @James_Cobbett — 2021-06-10T06:55:24Z

Thanks for the help everyone. Just wanted to close the loop on this in case anyone stumbles across this with an error of their own.

It turns out I had an issue in my production environment config file, which makes sense as to why it worked on staging and not production. I was using env() to get a environment variable, switching to getenv() has fixed it.

---

## Post 24 by @joshb — 2022-09-16T00:01:38Z

Hi James, just wanted to thank you for coming back and listing the reason you were having this error. I ran into this error yesterday after modifying my staging config and your thread here helped me out. :pray:
