Trellis hanging on installing dependencies

I was able to install Vagrant and run it within WSL fine on my Home computer, however, I still have the same issue on my work computer with running Vagrant and it producing the following error:

dannytaki@DESKTOP-DANNY:~$ vagrant
Vagrant failed to initialize at a very early stage:

The executable 'cmd.exe' Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.

I followed the download page running the following commands:

wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant

Before running those commands I uninstalled Vagrant following the documentation:

Output after running install commands:

dannytaki@DESKTOP-DANNY:~$ sudo apt update && sudo apt install vagrant
Hit:1 https://apt.releases.hashicorp.com focal InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:7 https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  vagrant
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/107 MB of archives.
After this operation, 258 MB of additional disk space will be used.
Selecting previously unselected package vagrant.
(Reading database ... 99367 files and directories currently installed.)
Preparing to unpack .../vagrant_2.3.1_amd64.deb ...
Unpacking vagrant (2.3.1) ...
Setting up vagrant (2.3.1) ...

Why am I getting this error and how do I resolve it? It looks like Vagrant command isn’t finding an executable from within WSL.

I just removed WSL and Ubuntu and reinstalling everything, lol.

Jesus, finally, that worked.

2 Likes

Glad you got it all sorted :rocket:

dannytaki@DESKTOP-DANNY:~/example.com$ trellis up
Starting galaxy role install process
- composer (1.9.0) is already installed, skipping.
- ntp (2.3.1) is already installed, skipping.
- logrotate (v0.0.5) is already installed, skipping.
- swapfile (v2.0.32) is already installed, skipping.
- mailhog (2.3.0) is already installed, skipping.

Running command => vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The host path of the shared folder is not supported from WSL. Host
path of the shared folder must be located on a file system with
DrvFs type. Host path: /home/dannytaki/example.com/site
* The host path of the shared folder is not supported from WSL. Host
path of the shared folder must be located on a file system with
DrvFs type. Host path: /home/dannytaki/example.com/trellis
* The host path of the shared folder is not supported from WSL. Host
path of the shared folder must be located on a file system with
DrvFs type. Host path: .


exit status 1

Now I’m getting the following error. Do I need to set my local_path in wordpress_sites.yml in the group_vars->developement folder to a directory on my windows machine?

Here’s a related topic: Trellis not compatible with WSL 2

If you search Vagrant for DrvFs you can see many related issues: Search · DrvFs · GitHub

Unfortunately I don’t know the best solution to fix it. Within those issues there’s some solutions about changing the mount type + location. Or reverting to WSL 1.

I don’t use Windows myself so I can’t test it and say for certain what will fix it. Thanks for your patience trying to troubleshoot this.

Why does the Trellis documentation recommend running it in WSL? Should I just run everything in Windows or are there issues there? What do you use Mac?

Also this may be a dumb question, but is Trellis commited to the Git Repository along with Bedrock code?

Yeah, it’s all in the same repo. trellis-cli creates a project with this structure:

example.com/      # → Root folder for the project
├── trellis/      # → Your server configuration (a customized install of Trellis)
└── site/         # → A Bedrock-based WordPress site
    └── web/
        ├── app/  # → WordPress content directory (themes, plugins, etc.)
        └── wp/   # → WordPress core (don't touch! - managed by Composer)

Why does the Trellis documentation recommend running it in WSL?

We recommend WSL because it is (or was) the easier way to run Vagrant and Trellis. It’s also a more consistent and closer experience to macOS and Linux hosts which means the rest of our documentation and tools (like trellis-cli) will apply more directly.

We’re obviously missing some more details on the proper WSL setup (especially in version 2) since it seems like Vagrant has some bugs.

Should I just run everything in Windows or are there issues there?

It should be possible and I know lots of people have done that over the years. Vagrant has a native Windows build (as you know from before); trellis-cli has a Windows build too (or you can follow the manual instructions on the docs).

Ok cool! I installed Linux on my PC just to get this working, haha. When I run Trellis up the first I’m getting this error:

daniel@daniel-H170-Gaming-3:~/example.com$ trellis up
Starting galaxy role install process
- composer (1.9.0) is already installed, skipping.
- ntp (2.3.1) is already installed, skipping.
- logrotate (v0.0.5) is already installed, skipping.
- swapfile (v2.0.32) is already installed, skipping.
- mailhog (2.3.0) is already installed, skipping.

Running command => vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-20.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-20.04' version '202206.03.0' is up to date...
==> default: Setting the name of the VM: example.test
==> default: Pruning invalid NFS exports. Administrator privileges will be required...
[sudo] password for daniel: 
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
exit status 1

However, running it immediately again gives me the following error:

daniel@daniel-H170-Gaming-3:~/example.com$ trellis up
Starting galaxy role install process
- composer (1.9.0) is already installed, skipping.
- ntp (2.3.1) is already installed, skipping.
- logrotate (v0.0.5) is already installed, skipping.
- swapfile (v2.0.32) is already installed, skipping.
- mailhog (2.3.0) is already installed, skipping.

Running command => vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-20.04' version '202206.03.0' is up to date...
==> default: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines...
==> default: [vagrant-hostmanager:host] Updating hosts file on your workstation (password may be required)...
==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

PLAY [WordPress Server: Install LEMP Stack with PHP and MariaDB MySQL] *********

TASK [Gathering Facts] *********************************************************
[WARNING]: Unhandled error in Python interpreter discovery for host default:
Failed to connect to the host via ssh: Connection timed out during banner
exchange  Connection to 127.0.0.1 port 2222 timed out
fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"127.0.0.1\". Make sure this host can be reached over ssh: Connection timed out during banner exchange\r\nConnection to 127.0.0.1 port 2222 timed out\r\n", "unreachable": true}

PLAY RECAP *********************************************************************
default                    : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
exit status 1

I see the VM is created in virtualbox too.

I ran Trellis Up a third time and received the following output:

daniel@daniel-H170-Gaming-3:~/example.com$ trellis up
Starting galaxy role install process
- composer (1.9.0) is already installed, skipping.
- ntp (2.3.1) is already installed, skipping.
- logrotate (v0.0.5) is already installed, skipping.
- swapfile (v2.0.32) is already installed, skipping.
- mailhog (2.3.0) is already installed, skipping.

Running command => vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-20.04' version '202206.03.0' is up to date...
==> default: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines...
==> default: [vagrant-hostmanager:host] Updating hosts file on your workstation (password may be required)...
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running action triggers after up ...
==> default: Running trigger...
==> default: Adding vagrant ssh-config for example.test to ~/.ssh/config

==> default: Machine 'default' has a post `vagrant up` message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default: 
==> default: Your Trellis Vagrant box is ready to use!
==> default: * Composer and WP-CLI commands need to be run on the virtual machine
==> default:   for any post-provision modifications.
==> default: * You can SSH into the machine with `vagrant ssh`.
==> default: * Then navigate to your WordPress sites at `/srv/www`
==> default:   or to your Trellis files at `/home/vagrant/trellis`.
daniel@daniel-H170-Gaming-3:~/example.com$ 

Running trellis ssh development gives me the following output:

daniel@daniel-H170-Gaming-3:~/example.com$ trellis ssh development
Running command => ssh vagrant@example.test
Error running ssh: exit status 255
daniel@daniel-H170-Gaming-3:~/example.com$ trellis ssh development
Running command => ssh vagrant@example.test
Error running ssh: exit status 255

My Vagrant version is Vagrant 2.3.1. Documentation says Vagrant should be:

Vagrant (opens new window)>= 2.1.0, < 2.2.19

I’m going to try to downgrade it to a previous version and run it again.

Just going from the outputs you’ve pasted, it doesn’t look like Vagrant has ever successfully provisioned the machine; it’s only booted up.

1st attempt: time out waiting for machine to boot
2nd: machines boots, but provision fails (Ansible playbook fails because it can’t SSH into the VM)
3rd: machine boots up, but because provision attempted to run before, it’s not run at all this time

There’s two ways to force a provision in Vagrant:

  1. destroy the box and run vagrant up
  2. run vagrant provision

Running Vagrant up from within the Trellis directory gives the following ouput:

daniel@daniel-H170-Gaming-3:~/example.com/trellis$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-20.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-20.04' version '202206.03.0' is up to date...
==> default: Setting the name of the VM: example.test
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Installing NFS client...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
[sudo] password for daniel: 
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 192.168.56.1:/home/daniel/example.com/site /vagrant-nfs-example.com

Stdout from the command:



Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported

I uninstalled Vagrant and reinstalled it using version Vagrant 2.2.18. I also deleted my /etc/exports file and recreated an empty file and deleted the VM and all associated files and still received the same error output on Mounting NFS Shared folders…

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 192.168.56.1:/home/daniel/example.com/site /vagrant-nfs-example.com

Stdout from the command:



Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported

So obviously there’s some issue with NFS.
There’s two options:

  1. switch to another mount type (even just temporarily)
  2. Fix NFS

To try another mount type, create a vagrant.local.yml file and add this:

vagrant_mount_type: virtualbox

To fix NFS, according to the Vagrant docs, both the Linux host and guest need NFS installed. On the guest this should be done automatically, so I assume your host OS is missing it.

I’m not sure what OS you’re running, but on Ubuntu you can do sudo apt install nfs-kernel-server. Here’s a decent looking page on troubleshooting it more.

edit: in either case, I suggest destroying the VM first and starting again.

Going to try the first option. I had already installed nfs-kernel-server and had it running in the previous attempts.