# Vagrant using Trellis on Windows 10 WSL2

**URL:** https://discourse.roots.io/t/vagrant-using-trellis-on-windows-10-wsl2/26345
**Category:** trellis
**Tags:** wsl, windows
**Created:** 2023-12-01T07:48:30Z
**Posts:** 26

## Post 1 by @decoycircuit — 2023-12-01T07:48:30Z

Trying to get Trellis up and running on Windows 10 WSL2.

Have followed the guide and things have been going great.

Until it’s time for `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.36) is already installed, skipping.
- mailpit (v1.0.0) is already installed, skipping.

Running command => vagrant up
Vagrant failed to initialize at a very early stage:

Vagrant is unable to use the VirtualBox provider from the Windows Subsystem for
Linux without access to the Windows environment. Enabling this access must be
done with caution and an understanding of the implications. For more information
on enabling Windows access and using VirtualBox from the Windows Subsystem for
Linux, please refer to the Vagrant documentation:

  https://www.vagrantup.com/docs/other/wsl.html
exit status 1
```

I follow instructions, and run the following from the URL above:

```
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
```

Once again, I run `trellis up` and get:

```
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.36) is already installed, skipping.
- mailpit (v1.0.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/user/site.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: /home/user/site.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
```

What am I doing wrong?

---

## Post 2 by @cheezman — 2023-12-01T11:56:50Z

Hello!

What is the filesystem set up of your main disk (where Windows is installed?)

The below article may be helpful:

> <https://github.com/MicrosoftDocs/wsl/blob/356d84161446d24551615848e80d04aab1e5f61d/WSL/wsl-config.md>

---

## Post 3 by @decoycircuit — 2023-12-01T15:29:03Z

Hey @cheezman!

I was hoping you’d chime in, as I understand you have several of these running. Almost tagged you to begin with!

This is a completely fresh Win10 installation, so whatever it is out of the box :slight_smile:

---

## Post 4 by @decoycircuit — 2023-12-01T20:35:45Z

@cheezman To answer your question, it’s NTFS

---

## Post 5 by @TechHedz — 2023-12-04T23:00:03Z

Were you able to get everything working?

I have been doing the same thing on NTFS. Not sure why I installed NTFS instead of exfat but I know it has some issues playing nicely with WSL but the necessary actions below are necessary for windows on any filesystem.

In WSL go to your wsl.conf file in the root etc folder. Add the line below to your profile

[automount]  
options = “metadata,umask=22,fmask=11”

Since you are mounting things in a directory outside of WSL you will also need to specify where WSL will need access on Windows. I put the access directing to my dev folder where I am keeping my projects by using the line below and typing it into the WSL prompt.

export VAGRANT\_WSL\_WINDOWS\_ACCESS\_USER\_HOME\_PATH=“/mnt/c/dev”

“/mnt/c/dev”, is the root folder where I keep my projects and that can be changed to what yours is.

Right now I can’t get the server pulled up when I goto to the site in a browser. I think everything is working since I can SSL into the vagrant machine trellis created but I can’t access the actual website. When I go to the local dev site at the \_\_\_\_\_\_\_\_.test page it refuses to connect. so I am currently stuck there trying to figure out what is going on. It might have something to do with my work firewall or something else but I am currently stumped.

---

## Post 6 by @decoycircuit — 2023-12-05T11:25:10Z

@TechHedz Hey David, and thanks for checking in.

I have not gotten it to work, but will try your suggestions when I get home tonight.

> Not sure why I installed NTFS instead of exfat

Hmm, would it even be advisable using exFAT on your Windows drive? I do use the machine as my daily driver.

Thanks again, will make sure to keep you posted.

---

## Post 7 by @TechHedz — 2023-12-05T16:46:34Z

exfat is better for compatibility between machines and supported by macs, Linux and so on. Windows NT is best if you only deal with windows. Maybe I was mistaken in mentioning exfat. I thought windows started to automatically use exfat but I may be wrong. I know exfat supports chmod which is good for changing permissions through WSL. I just don’t ever remember having problems with Trellis-CLI before on a windows machine like this. I’m on my work PC though and it could also be firewall and security protocols messing things up since we are pretty much locked down now.

---

## Post 8 by @decoycircuit — 2023-12-05T19:45:18Z

@TechHedz Back at it again, and unfortunately still not working.

I’m going to try removing everything and starting over. I figure I must be doing something wrong if I’m following the guide and it isn’t working?

---

## Post 9 by @decoycircuit — 2023-12-09T15:48:06Z

Quick update, still haven’t gotten it to work.

Apologies if this is obvious, but on WSL, is your dev folder supposed to be located inside the Windows file system, e.g. /mnt/c/dev/example.com? I realize this is what TechHedz said, just trying to understand how it works.

I’ve now tried to create the project within here, and it’s incredibly slow. I stopped it after 30 minutes. Or are you supposed to set it up in /home/User/example.com and then move it afterwards?

Tried that too, and that is just as slow.

Or are you supposed to create your project on the linux side and use some sort of symlink to the Windows FS?

Thanks very much guys, really trying here.

---

## Post 10 by @cheezman — 2024-01-03T12:05:06Z

@decoycircuit Hello!

Haha yes you can definitely tag me anytime, and apologies my delayed response, I’ve just returned from a period of offline time.

I’m also on NTFS so that should be just fine, are you still encountering the same issue after adjusting the wsl.conf as suggested by @TechHedz ?

@TechHedz if you’re able to access the machine via ssh, but it isn’t showing in the browser, it may be an issue related to your hosts file. You can try navigating to C → Windows → System32 → drivers → etc - \> hosts and adding the following two lines:

192.168.56.5 example.test  
192.168.56.5 www.example.test

(The IP would need to be 192.168.50.5) if you’re using an older version of trellis, but you can see this value by viewing your Vagrant config file in your Trellis project.

---

## Post 11 by @decoycircuit — 2024-01-05T15:34:32Z

@cheezman Thanks very much for getting back to this thread.

Yes, issue persist and I’m still not up and running.

My last post describes where I’m at.

1. I don’t see it in the docs, so asking it here. Are you supposed to run the trellis new setup command in the Linux or NTFS filesystem?

2. On further reading, I see people mentioning NFS. Are you supposed to install that?

I’m trying to piece it together.

Very much appreciated, thanks again.

---

## Post 12 by @cheezman — 2024-01-08T07:35:11Z

@decoycircuit Pleasure!

Alright, not a problem, seems like you’re in the final stretch :slight_smile:

1. `trellis new example.com` will need to be run from within your WSL environment. It may take a while on the “Installing dependencies” step.

2. NFS isn’t necessary no, the only two vagrant plugins I have installed are:

vagrant-bindfs (1.1.8, global)  
vagrant-hostmanager (1.8.9, global)

Let me know how the above goes :dancer:

---

## Post 13 by @decoycircuit — 2024-01-12T09:40:22Z

Thanks again, @cheezman, really appreciate the hand holding :slight_smile:

> `trellis new example.com` will need to be run from within your WSL environment. It may take a while on the “Installing dependencies” step.

Yes, thanks, that’s what I’m doing but what I’m asking is: Do I run the command within the `/home/user/dev` (linux) folder structure or the Windows one `/mnt/c/Users/user/dev`?

The reason I ask is, if I run in it /home/user/dev it’s super fast, but I get the error from a few posts up (even after running the ´export VAGRANT\_WSL …` commands.

If I run it (`trellis new`) in `mnt/c/Users/user/dev` it is incredibly slow – it takes 30 minutes for it to create, and sometimes times out.

Is this just how it works, or am I not doing it right?

Thanks again buddy

---

## Post 14 by @cheezman — 2024-01-12T11:02:15Z

@decoycircuit All good!

- You would run the command from within your **Windows** environment.
- I’ve just ran a `trellis new` from within my Linux folder and it completed successfully, however I also received the below error:

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

Please do try running a `trellis up` from within one of the projects you’ve created on your Windows filesystem.

My pleasure, let me know how it goes :sunglasses:

---

## Post 15 by @decoycircuit — 2024-01-12T11:48:55Z

@cheezman It’s working - at least within the mnt/c/Users/ path. But it is painfully slow, whereas if created in the Linux path (/home/user/dev) it’s close to instant.

Is that just how it is - I _have_ to create it in the Windows env? Or is there some sort of “link” I can create, allowing to maybe set it up under Linux? Sorry if I’m asking the same again, just want to make absolutely sure.

The error you’re getting is what I’m getting too (thanks for testing that out, btw) - but I was under the impression that is what I was fixing inputting the `export` commands?

I’ve now also gotten to installing Sage, following instructions. All works, but again, `yarn build` took:

```
❯ yarn build
yarn run v1.22.21
$ bud build

╭ sage [776635f9d9aa3c07] ./public
│
│ app
│ ◉ js/runtime.e97f88.js ✔ 1.22 kB
│ ◉ css/app.194f0a.css ✔ 5.35 kB
│ ◉ js/app.c6fc6f.js ✔ 359 bytes
│
│ editor
│ ◉ js/runtime.e97f88.js ✔ 1.22 kB
│ ◉ css/editor.ef46db.css ✔ ø
│ ◉ js/editor.8c1474.js ✔ 1.67 kB
│
╰ 1m 59s 451ms 8 modules [0/8 modules cached]

Done in 227.14s.
```

4 minutes for every build. Is that normal? It seems excessive to me

---

## Post 16 by @cheezman — 2024-01-12T12:42:47Z

@decoycircuit Glad!

From my experience, yes it has to be created from within Windows. You can definitely have a go at it, but I remember running into some permissions related errors (along with the shared folder error above).

Lovely stuff, I’ve run a yarn build now on a project of mine with a larger codebase and it compiled within 80s.

```
◉ js/391.dd35a4.js 248.4 kB
◉ css/app.8e021a.css 233.41 kB
◉ js/app.3be9cc.js 15.11 kB
◉ js/runtime.3ca2ea.js 1.11 kB
◉ js/editor.6e8560.js 376 bytes
◉ js/575.baac18.js 232 bytes
◉ css/editor.31d6cf.css 0 bytes
◯ images/Karbon-MediumItalic.62fad9.svg 442.38 kB
◯ images/Karbon-SemiboldItalic.6bf08c.svg 441.44 kB
◯ images/Karbon-Semibold.c2054b.svg 414.17 kB
◯ images/Karbon-Medium.be64d1.svg 412.77 kB
◯ images/Karbon-Light.fd61b5.svg 354.11 kB

+ 61 additional static assets

duration 10s 357ms (6s 459ms + 3s 898ms)

mode production hash 7ba1006fafc3d67b78a9
@roots/bud 6.3.3 webpack 5.73.0
node 16.10.0

Done in 84.45s.
```

What kind of machine are you running? Just out of curiosity, as I have an i7 processor (2.11GHz) with 16GB of RAM.

---

## Post 17 by @decoycircuit — 2024-01-12T12:48:57Z

@cheezman You’re a gentleman and a scholar :slight_smile:

Thanks for retesting my environment, that’s very nice of you.

> it compiled within 80s.

Got it- -in that case it’s probably not out of the ordinary for what I have going on.

I’m also on an i7 with 32 gigs of RAM, albeit an older i7.

---

## Post 18 by @decoycircuit — 2024-01-12T13:58:54Z

Follow up: From reading reports, it looks like slow speeds from file system to file system within WSL is quite common.

Last issue: I run `vagrant up` within `/trellis` and it starts up the VM.

However, I cannot access the site in the the browser on the .test domain.

`wordpress_sites.yml`:

```
wordpress_sites:
  mysite.com:
    site_hosts:
    - canonical: mysite.test
      redirects:
      - www.mysite.test
    local_path: ../site
    admin_email: admin@mysite.test
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false
```

I see the entries in my /etc/hosts:

```
## vagrant-hostmanager-start id: 5e16476f-1386-4db7-a89f-7da2d3a
192.168.56.5 mysite.test
192.168.56.5 www.mysite.test
## vagrant-hostmanager-end
```

It’s not at all trying to connect. Can’t reach it via the IP above, either.

What could be going on here?

---

## Post 19 by @cheezman — 2024-01-15T07:27:54Z

@decoycircuit Hiya! Just a few questions from my end:

- Did the initial `vagrant provision` or `trellis provision development` complete successfully?
- What is the value of vagrant\_ip in your trellis folder → vagrant.default.yml?
- Are the lines you’ve shared also present in your Windows hosts file? (C → Windows → System32 → drivers → etc - \> hosts)

---

## Post 20 by @decoycircuit — 2024-01-15T19:22:40Z

@cheezman by all means, ask away!

- Can’t get any sort of provisioning to complete. Neither `trellis ssh development`, `vagrant provision`, `trellis provision development` – and `vagrant ssh` doesn’t do anything.

`trellis ssh development` returns:

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

```
❯ trellis provision development
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.36) is already installed, skipping.
- mailpit (v1.0.0) is already installed, skipping.

Running command => ansible-playbook dev.yml --inventory-file=.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -e env=development

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: ssh: connect to host 172.18.208.1 port
2222: Connection timed out
fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"172.18.208.1\". Make sure this host can be reached over ssh: ssh: connect to host 172.18.208.1 port 2222: Connection timed out\r\n", "unreachable": true}

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

exit status 4
```

There appears to be issues with connecting via ssh.

- vagrant\_ip in `vagrant.default.yml`:  
`vagrant_ip: '192.168.56.5'`

- The lines I’ve shared are **NOT** present in my Windows hosts (C → Windows → System32 → drivers → etc - \> hosts)

* * *

Upon reading up on this, I found this thread from '22 [Trellis hanging on installing dependencies - #23 by dannytaki](https://discourse.roots.io/t/trellis-hanging-on-installing-dependencies/23977/23)

I tried what seemed to be the solution:

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

It hasn’t really done anything.

---

## Post 21 by @decoycircuit — 2024-01-15T21:58:54Z

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](https://discourse.roots.io/t/ssh-timeout-on-vagrant-up-with-windows-10-wls2-virtualbox-wsl2-plugin-installed/22115/10) 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.

---

## Post 22 by @decoycircuit — 2024-01-16T07:35:52Z

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](https://discourse.roots.io/t/cant-access-roots-example-project-from-host/16824/2)

---

## Post 24 by @decoycircuit — 2024-01-16T19:09:55Z

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

---

## Post 25 by @cheezman — 2024-01-17T08:46:09Z

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

---

## Post 26 by @Boz_Bundalo — 2024-05-02T05:23:42Z

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.
