Vagrant using Trellis on Windows 10 WSL2

Following up: OK so I’m past the SSH issue, somewhat.

I finally landed on SSH timeout on vagrant up with Windows 10 + WLS2 (virtualbox_WSL2 plugin installed) - #10 by dome and that worked.

The solution is to disabled Windows Defender Firewall protection for vEthernet (WSL) Domain, Private, and Public profiles.

I ran trellis up and it run the entire build process, it looks like.

As per docs, I’m told to run trellis ssh development to access the VM.

Still getting:

❯ trellis ssh development
Running command => ssh vagrant@mysite.test
Error running ssh: exit status 255

But I can ssh into vagrant:

❯ vagrant ssh
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-83-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Jan 15 10:10:18 PM UTC 2024

  System load:  0.02880859375      Processes:             146
  Usage of /:   15.7% of 30.34GB   Users logged in:       0
  Memory usage: 33%                IPv4 address for eth0: 10.0.2.15
  Swap usage:   2%                 IPv4 address for eth1: 192.168.56.5


This system is built by the Bento project by Chef Software
More information can be found at https://github.com/chef/bento

@cheezman, what an absolute trooper you are. Thanks very much for lending a hand, means a lot.

Following up again:

So, trellis up now works and it does appear to build it all out correctly.

I still can’t reach the domain in the browser. mysite.test just returns “can’t connect”, and it happens immediately.

If I run curl mysite.com in the in WSL, it returns Wordpress-like HTML, so that seems to work.

Do I need to manually update the Windows hosts file? If so, with what? The IP for vagrant?

EDIT: To answer my own question, apparently Trellis is supposed to edit the hosts file, but with it being Windows, this process can be unreliable. The test domain should point to the IP of the VM. I’ll try that today when I get home. Discourse source

And there we have it, ladies and gentlemen.

Pointed my project domain at the VM IP in the Windows hosts file manually, and now I can reach my WP install on mysite.test.

The solution is to disable Windows Defender Firewall protection for vEthernet (WSL) Domain, Private, and Public profiles.

Thanks for following along. Special thanks goes out to @cheezman

2 Likes

@decoycircuit Ayy lovely news! Very happy to hear it :man_dancing:

There will likely be smaller issues cropping up in the future, but they’re quite descriptive and usually quite easy to troubleshoot (specifically during the provisioning step).

All the best with it!

1 Like

Coming in fairly late but trying everything to switch to Windows and set up projects like I have on my mac is really unusable. There are way to many issues with Trellis/Vagrant on WSL 2 and it’s really not a priority seamingly for anyone.

I’ve tried running every possible scenario. If you are trying to run it on DrvFS (meaning /mnt/c… ) folders WSL 2 has so many issues that performance is atrocius and barely usable and running trellis cli to create a new project and virtual environment gets stuck due to pip having issues on WSL 2 and DrvFS. It just gets stuck and won’t create a project.

Add to this if you want to have Dropbox like most people have to back-up your projects the issue with permissions is another headache when files are on DrvFS. The issue here is vagrant really. Not supporting filesystem within WSL 2 is really silly. Btw, it did work up until version 1.9.4 as it didn’t do the check for it.

On the other hand, if you want trellis cli to work as intended, you have to be inside the WSL 2 filesystem, but then Vagrant’s synced folders won’t work as you’ve noticed.

WSL 2 is just a toy at this point and really impractical for any reliable work. Maybe for some basic Ubuntu things if you want to mess with it but for actual serious development it’s definitely not ready. And this is just issue with Vagrant/Trellis. Wait until you try Docker.

At this point I am simply running Mac for coding and PC for 3d work, Unreal Engine and similar. Maybe things will get better with WSL 3, newer versions of Vagrant but it’s questionable if it will even happen.

1 Like