# SOLVED! Vagrant provision - Composer could not find composer.json with encrypted HD

**URL:** https://discourse.roots.io/t/solved-vagrant-provision-composer-could-not-find-composer-json-with-encrypted-hd/12497
**Category:** trellis
**Tags:** trellis
**Created:** 2018-05-18T20:15:01Z
**Posts:** 12

## Post 1 by @nontro — 2018-05-18T20:15:01Z

Hi

vagrant provision give me  
unable to connect to database, I’ve tried to leave the default values in vault.yml and wordpress\_sites.yml  
but the vagrant machine ins’t accessible

Any idea?

## This is the error: unable to connect to database, check login\_user and login\_password are correct or /root/.my.cnf has the credentials. Exception message: (2002, “Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)”) failed: [default] (item=default) =\> {“changed”: false, “item”: “default”}

## unable to connect to database, check login\_user and login\_password are correct or /root/.my.cnf has the credentials. Exception message: (2002, “Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)”) failed: [default] (item=127.0.0.1) =\> {“changed”: false, “item”: “127.0.0.1”}

## unable to connect to database, check login\_user and login\_password are correct or /root/.my.cnf has the credentials. Exception message: (2002, “Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)”) failed: [default] (item=::1) =\> {“changed”: false, “item”: “::1”}

unable to connect to database, check login\_user and login\_password are  
correct or /root/.my.cnf has the credentials. Exception message: (2002,  
“Can’t connect to local MySQL server through socket  
‘/var/run/mysqld/mysqld.sock’ (111)”)  
failed: [default] (item=localhost) =\> {“changed”: false, “item”: “localhost”}  
to retry, use: --limit @/home/luke/dev/projects/pedroripolgroup.com/trellis/dev.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
default : ok=31 changed=0 unreachable=0 failed=1

Ansible failed to complete successfully. Any error output should be

---

## Post 2 by @runofthemill — 2018-05-18T20:22:21Z

Is this a new Trellis install? If so, you should run `vagrant up` rather than `vagrant provision` on the first go.

---

## Post 3 by @nontro — 2018-05-19T13:13:16Z

It is a new installation (I reinstalled twice for differents problems)  
I runned first vagrant up and the virtual machine starts without problems and I can ssh in it  
Then I runned vagrant provision and the error appears

---

## Post 4 by @swalkinshaw — 2018-05-20T15:01:13Z

Can you SSH into the VM and run a few commands?

1. `vagrant ssh`
2. `mysql --user root -p` and enter the default pw `devpw`

If you can’t connect, check `sudo service mysql status`.

---

## Post 5 by @nontro — 2018-05-20T17:59:34Z

Hi Swalkinshaw

> [@swalkinshaw](#):
>
> `mysql --user root -p` and enter the default pw `devpw`

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)

> [@swalkinshaw](#):
>
> `sudo service mysql status` .

mariadb.service - MariaDB 10.2.14 database server  
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)  
Drop-In: /etc/systemd/system/mariadb.service.d  
└─migrated-from-my.cnf-settings.conf  
Active: failed (Result: exit-code) since Thu 2018-05-17 12:37:13 UTC; 171 years 11 months ago  
Docs: man:mysqld(8)  
[systemd - MariaDB Knowledge Base](https://mariadb.com/kb/en/library/systemd/)  
Process: 7408 ExecStartPost=/bin/sh -c systemctl unset-environment \_WSREP\_START\_POSITION (code=exited, status=0/SUCCESS)  
Process: 7404 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)  
Process: 7730 ExecStart=/usr/sbin/mysqld $MYSQLD\_OPTS $\_WSREP\_NEW\_CLUSTER $\_WSREP\_START\_POSITION (code=exited, status=1/FAILURE)  
Process: 7707 ExecStartPre=/bin/sh -c [! -e /usr/bin/galera\_recovery] && VAR= || VAR=`/usr/bin/galera_recovery`; [$? -eq 0] && systemctl set-environment _WSREP_  
Process: 7700 ExecStartPre=/bin/sh -c systemctl unset-environment \_WSREP\_START\_POSITION (code=exited, status=0/SUCCESS)  
Process: 7697 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)  
Main PID: 7730 (code=exited, status=1/FAILURE)  
Status: “MariaDB server is down”

May 17 12:37:13 example mysqld[7730]: 2018-05-17 12:37:13 139751284500672 [Note] InnoDB: Some operating system error numbers are described at [https://mariadb.com/kb/en/li](https://mariadb.com/kb/en/li)  
May 17 12:37:13 example mysqld[7730]: 2018-05-17 12:37:13 139751284500672 [ERROR] InnoDB: Cannot open datafile ‘./ibdata1’  
May 17 12:37:13 example mysqld[7730]: 2018-05-17 12:37:13 139751284500672 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data fil  
May 17 12:37:13 example mysqld[7730]: 2018-05-17 12:37:13 139751284500672 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file  
May 17 12:37:13 example mysqld[7730]: 2018-05-17 12:37:13 139751284500672 [Note] InnoDB: Starting shutdown…  
May 17 12:37:13 example mysqld[7730]: 2018-05-17 12:37:13 139751284500672 [ERROR] Plugin ‘InnoDB’ init function returned error.  
May 17 12:37:13 example systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE

---

## Post 6 by @swalkinshaw — 2018-05-20T18:12:28Z

So it’s not running for some reason.

Try `sudo service mysql start`. If it starts, then cool. If not, paste whatever error it says.

And maybe try re-installing it if it fails:

```
sudo apt-get purge mariadb-server mariadb-client
```

Then re-run `vagrant provision`.

---

## Post 7 by @nontro — 2018-05-20T20:46:24Z

> [@swalkinshaw](#):
>
> `sudo service mysql start`

**Job for mariadb.service failed because a fatal signal was delivered causing the control process to dump core. See “systemctl status mariadb.service” and “journalctl -xe” for details.**

I tried to remove Maria Db but the machine crashed and after that looks like corrupted;  
I tryend vagrant halt and vagrant up but nothing happened.

So I run vagrant destroy and than vagrant up  
and it created the machine with this error:  
\*\* [WARNING]: - composer was NOT installed successfully: Failed to get data from  
the API server ([https://galaxy.ansible.com/api/](https://galaxy.ansible.com/api/)): Failed to connect to  
[galaxy.ansible.com](http://galaxy.ansible.com) at port 443: [Errno -2] Name or service not known

ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.  
Ansible failed to complete successfully. Any error output should be  
visible above. Please fix these errors and try again.  
\*\*  
anyway I tried to vagrant provision and this was the error:

Composer could not find a composer.json file in /srv/www/example.com/current  
To initialize a project, please create a composer.json file as described in  
the [https://getcomposer.org/](https://getcomposer.org/) “Getting Started” section  
failed: [default] ([item=example.com](http://item=example.com)) =\> {“changed”: false, “item”: “[example.com](http://example.com)”, “stdout”: “Composer could not find a composer.json file in /srv/www/example.com/current\nTo initialize a project, please create a composer.json file as described in the [https://getcomposer.org/](https://getcomposer.org/) "Getting Started" section\n”, “stdout\_lines”: [“Composer could not find a composer.json file in /srv/www/example.com/current”, “To initialize a project, please create a composer.json file as described in the [https://getcomposer.org/](https://getcomposer.org/) "Getting Started" section”]}

**Note** I installed composer through brew (linuxbrew)  
(Warning: composer 1.6.5 is already installed and up-to-date  
To reinstall 1.6.5, run `brew reinstall composer)

---

## Post 8 by @swalkinshaw — 2018-05-21T17:12:28Z

Looks like you’re running into a lot of unusual errors :frowning_face:

That Composer issue was definitely just a network connectivity one which can obviously happen but we can’t do much about it. But as you saw, you won’t be able to provision properly without Composer installed and working.

I can only suggest the usual `vagrant destroy && vagrant up` solution. If any errors happen during that process, it’s likely it won’t work properly.

---

## Post 9 by @nontro — 2018-05-28T16:53:32Z

So I tried and tried and that is what I’ve understood:

my linux partition is encrypted and whenever I vagrant Up I get an NFS problem. (its a common issue and I have no idea how to solve it)

So I tried to move my dev directory in a secondary HD; I destroy the vm and I vagrant up again but I am getting a composer error

> Blockquote  
> Composer could not find a composer.json file in /srv/www/mush-  
> [shop.com/current](http://shop.com/current) To initialize a project, please create a composer.json file  
> as described in the [https://getcomposer.org/](https://getcomposer.org/) “Getting Started” section  
> failed: [default] ([item=mush-shop.com](http://item=mush-shop.com)) =\> {“changed”: false, “item”: “[mush-shop.com](http://mush-shop.com)”, “stdout”: “Composer could not find a composer.json file in /srv/www/mush-shop.com/current\nTo initialize a project, please create a composer.json file as described in the [https://getcomposer.org/](https://getcomposer.org/) "Getting Started" section\n”, “stdout\_lines”: [“Composer could not find a composer.json file in /srv/www/mush-shop.com/current”, “To initialize a project, please create a composer.json file as described in the [https://getcomposer.org/](https://getcomposer.org/) "Getting Started" section”]}

> Blockquote

I am thinking to give up and build manually a wordpress Virtualbox to clone when I start a new project.

---

## Post 10 by @nontro — 2018-05-30T20:05:52Z

**Solved!** :sparkler: :sparkler:

At the end I discovered that isn’t possible to install in a HD encrypted (a NFS directory issue comes up)

Steps I take to make it work in Ubuntu 18.04 LTS (Bionic Beaver) :

- I’ve wiped a secondary HD (dd if=/dev/zero of=/dev/sdX bs=1M \*replace X with the target drive letter)
- I create a new directory and followed this step by step tutorial [https://www.youtube.com/watch?v=Ls30HGKru8A](https://www.youtube.com/watch?v=Ls30HGKru8A)
- before vagrant up I’ve installed those two vagrant plugins:  
a) vagrant plugin install vagrant-bindfs  
b) vagrant plugin install vagrant-hostmanager

**And it’s works perfectly!**

---

## Post 11 by @ben — 2018-05-30T20:40:32Z

> [@nontro](#):
>
> At the end I discovered that isn’t possible to install in a HD encrypted (a NFS directory issue comes up)

This has come up many times now, sorry about that. I’ve noted it near the top of [https://roots.io/trellis/docs/local-development-setup/](https://roots.io/trellis/docs/local-development-setup/)

---

## Post 12 by @swalkinshaw — 2018-06-01T02:21:58Z

Thanks for sticking with this and sharing your solution :heart:
