New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for Windows with WSL Windows Interoperability improvements #1012

Closed
geerlingguy opened this Issue Nov 23, 2016 · 18 comments

Comments

5 participants
@geerlingguy
Owner

geerlingguy commented Nov 23, 2016

See: Bash on Ubuntu on Windows - Windows Interoperability.

Basically, we can now invoke Windows executables straight from bash under the WSL, without having to use something like cbwin (which is currently recommended in the docs: http://docs.drupalvm.com/en/latest/other/windows/#windows-subsystem-for-linux-ubuntu-bash).

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Dec 2, 2016

Was going to test this today... got everything upgraded on the ol' Win10 laptop, then realized that Build 14951, which has the update enabling this functionality, seems to be only available at this time to those in the Windows Insider Preview community.

See Windows 10 update history here: https://support.microsoft.com/en-us/help/12387/windows-10-update-history

As I'd rather not change the entire contents of my lone old PC laptop just to test this feature, I'll wait until it makes it's way into a general Windows 10 build (right now I'm on Anniversary, which is build 14393.447).

Once there, the command to call Vagrant (in it's default location on Windows) would be:

$ /mnt/c/HashiCorp/Vagrant/bin/Vagrant.exe up

Note that you could add /mnt/c/HashiCorp/Vagrant/bin to your $PATH in Ubuntu Bash, and then you'd be able to call Vagrant.exe up. You can also assign aliases as you normally would if you want to call commands like vup etc.

@geerlingguy geerlingguy added the planned label Dec 2, 2016

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Mar 25, 2017

Still waiting...

See also a recent post on how to use Drupal VM + Acquia BLT on Windows 7/8, in the mean time.

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 5, 2017

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 7, 2017

Downloading Creators' Update now (see: Microsoft/WSL#333 (comment)). I'm going to see if I can:

  1. Get Vagrant.exe executable within WSL.
  2. Do everything for Drupal VM setup using just the WSL.
  3. Use things like Composer from WSL to set everything up for an entire new project without resorting to Cmder or running stuff inside the VM.
@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 7, 2017

Hmm... it seems that the pass-through doesn't preserve environment on the Linux side—if I just try using vagrant.exe Vagrant tries running within Windows' path, and not in the current working directory.

Someone has directions for installing Vagrant inside Ubuntu, and having it call out to VirtualBox running in Windows using some pathing trickery: Microsoft/WSL#733 (comment)

But that feels ridiculously clunky and prone to breakage. There must be some way to tell Vagrant it's being run within the WSL environment, so I'm going to see if that's possible. And if not, maybe just give some feedback over in the Vagrant issue queue: hashicorp/vagrant#7731

See also, blog post by someone else trying to get things working in some sort of clean way: What I’ve learned: setting up Bash/Ubuntu/Win10 for Ansible + Vagrant + VirtualBox.

Sadly, it's looking like it may still be simplest to recommend Windows users use Cmder, because Ubuntu Bash can't (AFAICT) cleanly call vagrant.exe preserving the current working directory or anything else Vagrant needs to know about the current project.

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 7, 2017

If I just run vagrant.exe --help (or anything else), it returns:

Unable to translate current working directory. Using C:\WINDOWS\system32
@bitcrazed

This comment has been minimized.

bitcrazed commented Apr 9, 2017

Consider a few things here:

  1. Windows knows very little about these Linux processes running ELF-64 binaries in their own "foreign" environment.
  2. So when you run a Windows exe from within a filesystem path (e.g. ~/) that the .exe can't find and doesn't understand, Windows displays "Unable to translate current working directory. Using C:\WINDOWS\system32". If you first change to a Windows-accessible directory, you won't see this issue:

image

  1. When you run vagrant.exe, it is launched within Windows and knows little/nothing about the Linux environment - it's the equivalent of launching vagrant.exe from Cmd/PowerShell
@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 10, 2017

@bitcrazed - Ah, you're quite correct! I went into my home directory in Windows (/mnt/c/Users/jeff.geerling) and ran vagrant.exe up and it's currently building a copy of Drupal VM. All the commands I ran in sequence (inside Ubuntu Bash) were:

  1. export PATH=$PATH:/mnt/c/Windows/System32
  2. cd /mnt/c/Users/jeff.geerling
  3. git clone https://github.com/geerlingguy/drupal-vm.git
  4. cd drupal-vm
  5. vagrant.exe up

Next up, I'll check if vagrant ssh can work in this environment, or if more trickery will be necessary.

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 10, 2017

vagrant.exe ssh doesn't work since Vagrant doesn't know it's running in the Ubuntu Bash environment. However, running vagrant.exe ssh-config, then running ssh -p [port] vagrant@127.0.0.1 does allow me to log in (password is vagrant).

I couldn't easily use the insecure_private_key Vagrant ships with due to permissions issues accessing it from the Ubuntu Bash environment. And this is slightly clunky in general, but it does at least work... vagrant.exe provision works fine, though it doesn't pass through environment variables (e.g. to do DRUPALVM_TAGS=tag vagrant provision you need to do it in Cmder or elsewhere).

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 10, 2017

I left some notes in the Vagrant issue I mentioned earlier: hashicorp/vagrant#7731 (comment)

Maybe we can find a way to get Vagrant itself to play more nicely inside the Ubuntu Bash environment?

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 10, 2017

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented May 10, 2017

WAHOO!!! Vagrant just merged full support for running vagrant native inside WSL: hashicorp/vagrant#8570

Looks like the process will get a bit easier...

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented May 21, 2017

Vagrant 1.9.5 is the solution I've been looking for: https://github.com/mitchellh/vagrant/blob/v1.9.5/CHANGELOG.md

@brentratliff

This comment has been minimized.

brentratliff commented Jul 26, 2017

I've been using drupalvm for about 6 projects over the last couple of years on Mac but have recently switched to Windows to try WSL. I'm happy to test this if you need someone else to give feedback. My laptop is still Mac so I use drupalvm on that but have been playing around with Docker/Lando on the Windows side with both WSL and PowerShell on my workstation and Surface. I wasn't able to enable VT-d with my Hackintosh but it is enabled on Windows now so I want to see if the performance is better with Docker. Also going to try drupalvm/docker to see how that works.

@bostonmoto

This comment has been minimized.

bostonmoto commented Mar 27, 2018

@geerlingguy Thanks for your updates here. Based on your last comment about support in WSL. What changes in the steps you listed above? For example is it still necessary to source the windows system files inside bashrc and invoke vagrant windows exe via the linux shell?

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Apr 24, 2018

@bostonmoto - Basically, yes. I haven't had time to do any full-scale testing recently, but I finally have a newer Dell XPS 13 with Windows 10 Pro and a bit more processing power that I am hoping to spend some time testing Drupal VM under WSL (but using the Windows 10 system's Vagrant.exe to manage it)... we'll see where that goes.

@BR0kEN-

This comment has been minimized.

BR0kEN- commented Apr 24, 2018

Here is a half-automated instruction to run Vagrant + VirtualBox on WSL - https://cikit.tools/documentation/install-on-wsl/.

@geerlingguy, let me know if I have to remove the link because it advertises the development I made.

@geerlingguy

This comment has been minimized.

Owner

geerlingguy commented Oct 10, 2018

Closing this for now, I would posit the best way to do things on Windows is to follow along with the myriad of blog posts out there from people who use Windows day-in and day-out. I will continue to offer what minimal amount of support for Windows as I can, but over time it has become harder to keep up with all the changes, especially when every few months when I boot up my PC it decides to spend a few hours updating itself (insert frustration emoji here).

Rather than leave this issue open forever, I'll open specific issues when the need arises, or when I get time/motivation to do more testing in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment