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

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

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

1 Like

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

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.

Hi Swalkinshaw

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

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
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
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

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.

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/): Failed to connect to
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/ “Getting Started” section
failed: [default] (item=example.com) => {“changed”: false, “item”: “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/ "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/ "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)

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.

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 To initialize a project, please create a composer.json file
as described in the https://getcomposer.org/ “Getting Started” section
failed: [default] (item=mush-shop.com) => {“changed”: false, “item”: “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/ "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/ "Getting Started" section”]}

Blockquote

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

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
  • 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!

2 Likes

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/

3 Likes

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

1 Like