Vagrant using Trellis on Windows 10 WSL2

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?

Hello!

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

The below article may be helpful:

1 Like

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:

@cheezman To answer your question, it’s NTFS

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.

1 Like

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

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.

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

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.

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

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

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

2 Likes

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

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

@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

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

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

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?

@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)
1 Like

@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

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.