614 points · by mococa · 5y ago · 408 comments
I've had only two problems with this set up:
- Occasionally VS Code Typescript features slow down, but it fixes itself a few days later (maybe after a restart). I presume this is due to the WSL Remote, but not certain.
- The occasional line endings snafu, but this is more of a tooling issue.
I expected to hate it, but I'm asking myself why I didn't do this sooner.
It's the same sort of scenario as before -- I have Windows running the games I occasionally play, and music stuff, and I do all of my code stuff in WSL2/Ubuntu.
But this way, I never have to fiddle with weird WINE patches or googling bugs, everything "just works". Asking myself why I didn't do this sooner to be honest.
I had one big complaint which is that copying files from Windows to WSL2 would create ".ZoneInfo" file copies of every file, that was downloaded from the web, but they patched this recently too.
With the support for Linux GUI apps that launched with Windows Insider Preview recently, I have a hard time making arguments against it now. The taste of crow is a little bitter, eh.
Linux + WINE/Proton basically felt like shittier, more bug-ridden Windows + WSL2. With the one notable exception that as an OS/host, Windows 10 "feels" a bit slower in general.
https://www.cicoria.com/improving-windows-subsystem-for-linu...
https://www.reddit.com/r/bashonubuntuonwindows/comments/eok7...
"I noticed a significant performance difference after adding exclusions to the Windows Defender. My Rails server and NPM installs sped up dramatically (I mean like 4x faster, no joke)."
Stupid.
https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
Currently, the mount is not automatic so you can make a startup.ps script and run it on start through group policy.
AAAAAAAAAAAAAAAAAAAAAAAAAAAARGH.
Defender kept trying to quarantine my Windows hosts file so I had to add it as an exception but then 3 weeks later it started doing the same to my WSL2 Ubuntu's unmodified hosts file.
I'm glad I opted for Ubuntu and manually installing tools that I need instead of using the Kali subsystem. I couldn't imagine the headache that'd have created.
WSL2 linux distros are not equal to bare metal linux distros. WSL2 Debian doesn't have systemd installed and what a fvckery it is trying to get it to work. That means sshd, docker, k3s don't work as expected on reboot. Some apps do not install properly becasue scripts expect systemd. Windows networking is PITA too just to do something simple like SSH into a WSL2 instance.
I don't get why deep Windows integration is so important. It's not something I would use on a production box. I just want Hyper-V to work like VMware and VirtualBox. As you say, VSCode remote makes it all seamless anyway.
I had to go back to VMware 15.5.2 (version before hyper-v layer) and disable hyper-v completely.
Isn't that just more of the same bullshit hoop jumping?
Everytime I hear about how great someone's wsl setup is I roll my eyes because it inevitably involves some rediculously convoluted wrangling to the nth level for something that is relatively basic on native Linux.
And these people rarely have an excuse for why they prefer windows over say fedora which has been a better than windows windows experience since windows 8.
Edit, wow even this thread people are suggesting the most drastic of things, let's run an entirely separate hard drive, oh but you need to fiddle with startup scripts because it couldn't be automatic.
But it’s not jumping through hoops? I just either run `code .` (like I did on macOS) or select recent folder from within VS Code. It all just works fairly well, identical to ‘natively’ within Windows (except the occasional ts slowdown I mentioned before).
> And these people rarely have an excuse for why they prefer windows
Not that anyone needs an ‘excuse’ for their personal preference, but I would actually prefer macOS. But I got a Windows PC to use software that only runs on Windows (games) and then the whole wfh thing happened and here we are. I’m not interested in rebooting between different operating systems when I switch tasks, especially when they overlap (developing for games).
Convince Bungie to port their game to macOS and I’ll buy a Mac Pro to be back home on a Mac full time :)
With good humor, his describes my experience with Linux distros since I first started using them. Doing just about anything seems to require some convoluted wrangling. :)
Sounds like last time I tried Linux on the desktop.
...maybe 2021 is finally the year of the linux desktop...
- WSL2 sometime corrupt .zsh_history and git https://github.com/microsoft/WSL/issues/5026
- WSL2 corrupts ext4 filesystem https://github.com/microsoft/WSL/issues/5895
From what I’ve seen it’s a combination of the storage drivers and the storage virtualisation in HyperV rather than a specific issue. I imagine it’s something similar in WSL.
I really don’t trust it as a platform at all. It’s barely better with windows guests.
Best option is still vbox and putty IMHO. VScode will work with it and SSH fine.
Or say fuck it, buy a Mac and do all your Linux work in the cloud.
What are you talking about, that is how you diagnose a Windows box...
A bigger problem would be if Hyper-V is either ignoring memory barriers, or caching writes to the disk and losing them when the Hyper-V service is shutdown. But that would likely affect more than just WSL, so we'd have seen the problem sooner (or so I vehemently hope).
I used to have occasional problems with this setup, and it was always some kind of drive corruption or mounting issue. I wonder if this is related?
I assumed that had all been fixed by now, but yeah, these things can get tricky fast.
[1]: https://lwn.net/Articles/322823/
[2]: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/317781/...
as far as I know when wsl2 is actiavted, hyper-v runs as type-1 and linux, windows are virtual after activating it.
thus if it crashes, you get a bsod
WSL2 being Linux means that, unlike WSL1 which directly uses the host NTFS filesystem, it's probably using an emulated block device to hold its filesystem. If that emulated block device doesn't correctly honor write barrier requests from the Linux kernel, it could explain the corruption.
* the kernel is not properly shutdown (and sometimes some buffers are not flushed)
* the virtual block device and/or its linux driver has bugs
The biggest issue across all these things is filesystems. There is simply no good way to share a filesystem between Windows and Linux that is both 1. fast 2. fully correct - i.e doesn't break some code.
SMB/NFS just never work super well because they are slow, or programs think they are local filesystems so things break (e.g VScode won't detect new files created on the linux side of a SMB mount without a manual refresh). Plenty of details on getting permissions right too. Not to mention extended attributes which differ slightly and break stuff. Network file systems in general are just too different to local FS's for programs to work seamlessly.
The 2 non-ideal solutions I've found are 1. keep all files in linux + edit over network using VSCode Remote or IntelliJ Remote support or 2. keep a copy of the dev workspace in windows, and use something like unison (or manual git) to sync.
tl;dr WSL2 bash is not bash but it pretends to be and there are terrifying changes to the semantics of bash scripts as a result.
The predecessor, WSL, "just worked" and it was more a less a linux experience for most practical purposes-- and certainly better than hoary old cygwin.
This caused a lot of people to believe they could just transition to WSL2, lead on by the promise of an even more performant linux experience. The documentation didn't say anything about complications from attempting this, so a lot of people just tried it as soon as they could, thinking it would go as smoothly as when they tried WSL. But nope... it many cases, it doesn't just work out of the box. There's network configuration and gateway issues, snags with vpn, and now this git repo corruption. When you look on git issues, it's just people randomly shot-gunning suggestions, some of which work, some of which don't. I think WSL2 was rushed out too early, or at least it's lacking a comprehensive troubleshooting guide to get it up and running.
I'd say WSL2 team, because it worked well in the original WSL.
FWIW I am a user moderator down there and VMware desktop products (Workstation/Fusion/Player) has my focus and as a result I basically read almost every post that would report this issue.
I just DDG'ed it and see one report from 2014 [0], ok some more from around 2008 when using google.
Looks like this was resolved in 2015 as that was the last time I see it being mentioned.
Took quite some time to figure out what was causing it. "Everyone is somehow corrupting files except for me, wtf?" Magic filesystem translation layers always suck
I can't recall what made me start doing that, but now it's a habit.
So, to me, it looks like WSL2 not completely flushing writes to the underlying file system. Bad, but not as bad as file system corruption (which could lead to losing all data on the disk)
The first instance of a problem is:
[ 1.956835] JBD2: Invalid checksum recovering block 97441 in log
And that's corruption that leads to log replay failing, i.e. rejecting it because honoring the replay in the face of checksum errors could make things much worse. Subsequently mount fails: [ 21.151232] ERROR: MountExt4:1659: mount(/dev/sdb) failed 5
That's good because the purpose of journal replay is to make the file system consistent following a crash/power fail. And if the file system is dirty, replay is called for, but can't happen due to a corrupt journal, so now an fsck is required. i.e. it is in an inconsistent (you could say partly broken) state and needs repair.I haven't seen syslog/systemd journal for other cases to know if there's instances of ext4 log replay that succeeds, but with missing files. That's not file system corruption, even if it leads to an inconsistent state in a git repository (or even a database). But this is still concerning, because to get a situation where log replay is clean but files are missing suggests an entire transaction was just dropped. It never made it to stable media, and even the metadata was not partially written to the ext4 journal.
qemu-kvm has a (host) cache setting called "unsafe". Default is typically "none" or "write back". The unsafe mode can result in file system corruption if the host crashes or has a power failure. The guest's IO is faster with this mode, but the write ordering expected by the file system is not guaranteed if the host crashes. i.e. writes can hit stable media out of order. If the guest crashes, my experience has been that things are fine - subsequent log replay (in the guest) is successful, because the guest writes that made it to the host cache do make it to stable media by the same the guest reboots. The out of order writes don't matter... unless the host crashes, and then it's a big problem. The other qemu cache modes have rather different flush/fua policies that can still keep a guest file system consistent following a host crash. But they are slower.
So it makes me suspicious that for performance reasons, WSL2 might be using a possibly volatile host side caching policy. Merely for additional data point, it might be interesting to try to reproduce this problem using e.g. Btrfs for the guest file system. If write order is honored and flushed to stable media appropriate for default out of the box configuration of a VM, I'd expect Btrfs never complains, but might drop up to 30s of writes. But if there's out of order writes making it to stable media, Btrfs will also complain, I'd expect transid errors which are also a hallmark of drive firmware not consistently honoring flush/fua and then you get a badly timed crash. (And similar for ZFS for that matter - nothing is impervious to having its write order expectations blown up.)
Also over the years it seems like everyone I've seen that habitually edits files remotely ends up with this sort of pain and butthurt.
Source: https://en.wikipedia.org/wiki/VMware_Workstation#Version_his...
Postgres never worked for example natively. Several npm modules would fail when running webpack.
wsl2 worked perfectly for these cases.
I wonder if people are mounting an ntfs volume in wsl2 which is really slow and janky?
We (postgres) did fix an ENOSYS (missing syscall) problem at some point so WSL could run Postgres. The surprising thing for me was how long it took for anyone to tell us it was broken/spewing warnings. That was forced when we changed a warning to a panic.
From reading the issue and related ones, it sounds like it might be related to some sort of unpredictable unclean VM shutdown.
> Postgres never worked for example natively.
That's a minor incovenience at worst.
I will stay put in WSL1. If I wished a VM I would have just installed VMWare and run some Linux ISO image from it.
What a bizarre claim. It's irrelevant if you don't need Postgres, a minor inconvenience if you can easily adopt a workaround, and a show stopper if you were relying on accessing a local Postgres instance.
The level of inconvenience purely depends on your stack and how its developed. Often things which don't bother me have huge effects on other members of my team, or on people working on other projects.
I tried WSL because I thought it would be faster than a heavyweight VM. Turned out it's dog slow in comparison.
Honestly don't see a use for it.
The reason $MSFT loves open source is because they can get press hype over projects that are 75% complete (which is the main goal), and they don't even need to support it, document it, or make it actually work.
What's even worse is they have managed to abstract most of the support away in this cycle. You can't get enterprise support now because they gutted that entirely. You can't get them to do anything on github because they keep moving all the projects around and erasing them all or auto closing the tickets and no one on first line support knows anything now other than how to reset a Microsoft account password.
They're following the "rules" from "The Cathedral and the Bazaar", remember. Specifically, the "Release early and often" bit, for the purposes of this conversation. Microsoft are considered "good open source citizens" because of the changes they've made to follow the written non-rules as well as the the unwritten rules.
If you're going to fault Microsoft for following the rules, fault EVERYONE ELSE that does it as well.
I want people to realize that they crap on Microsoft hard for things that they gladly accept from other developers or other companies. The double standards in the IT community are absolutely insane.
who would've thought that managing hundreds of repos with shitton of issues, dependencies and people is difficult to get at 1st attempts
We discussed this here before: I am reasonably certain -- without having any insider info -- it was various ptrace types which broke the camel's back besides the abhorrent file system performance. Both PTRACE_SEIZE and PTRACE_TRACEME was closed as fixed-in-wsl2 https://github.com/microsoft/WSL/issues/2028 https://github.com/microsoft/WSL/issues/3031
I upgraded to WSL2 because well 2 is bigger than 1 so it must be better. But no, nothing worked. Serial ports are not supported in WSL2.
Here's how you can flash ESP devices under WSL2.
You can have WSL1 and WSL2 side by side IIRC. And there are scripts out there to pipe serial into WSL2.
Well. Has cygwin ever corrupted get repos?
Other issues which colleagues encountered include abysmal performance and broken python installations as PATHs and other environment details are wildly mixed inside WSL.
I just don’t understand why some people were seemingly happy with WSL1, there were so many rough edges. WSL2 is much much better in my experience, on virtually all fronts.
The problem is software that is badly written and does bad assumptions, like that continuing opening/closing files is good just because in Linux is good, that maybe true on most UNIX systems but nobody said that.
I think that WSL2 is a very very bad idea, you are no longer making a POSIX subsystem of Windows, a way to use the POSIX API in the Windows kernel, without any emulation (basically the same thing as WINE), you are running a virtual machine.
I would say that WSL2 performance is very bad if you work in the Windows filesystem. Sure, if you work from the WSL home directory that is mounted in a ext4 virtual filesystem performance is good, it's a VM.
But this is useless, you see the main advantage of WSL over having a VM or a dual boot was integration with Windows, the ability to use bash scripts to manipulate your Windows files, the ability to launch Windows executables and pipe the output into a POSIX executable.
All of that is useful if there is a strong connections between the two systems, if I can work with WSL in the same home directory as Windows where I have all my files. How is useful if before working on something (that could be a stupid thing like running a script to rename a bunch of files) I have to first copy the files that I intend to work on in the WSL home, run what I have to turn, and copy them back? And what if I want my IDE in execution in Windows with the project in Windows and I want to launch on the project bash scripts?
I hope they will not discontinue WSL1! If they will discontinue WSL1, unfortunately I will have to go back to cygwin that was not great but worked mostly fine, since I need integration between Windows and Linux.
I'm actually surprised they can't be used together.
Say what you want about cygwin, but it never did this.
For native linux, I have my choice of distro installed on my choice of hypervisor (Debian, VMWare).
I use VSCode and the Remote SSH extension (functions identically to WSL2). The difference is I know exactly what is going on. I know when and why certain network conditions exist (port forwarding, etc).
Nonetheless I hope this gets fixed before it hits me.
The MBP M1 has blown me away, I don't think I'll try to go back any time soon.
Combine this with Endpoint Management crapware from my employer and you have a toxic combination. Esp. as said crapware is primarily targeted and optimized for WIN machines as the parent company is > 500k WIN machines and only about 25k - 40k Mac machines.
Sad, as I really loved the pre 2018 MB Pros and it was a blast doing my data analysis work there.
Is this confirmed by anyone else?
Thanks for keeping it so bad that you can't even push to a repo without corrupting the filesystem or the repo itself.
It might have supposed to be EEE, but it turned out to be the last push many people needed to switch to a full Linux OS.
If you have 2 different git clients (different git versions) accessing the same shared .git directory, bad things can happen -- incorrect file status, iirc.
I wish I can use a real Linux installation but their display drivers don't work well with my multiple displays with different resolutions
Unless you're writing through a time warp from 2004, this is not true at all, IME.
But the statement is vague. "Work well" can mean some esoteric DPI scaling stuff that I think is only noticeable with 4K combinations. What distribution? What's "their display driver"? Nouveau, the open-source Nvidia one, is pretty bad, and everyone uses the proprietary Nvidia driver (this may be hard to come by on some distros, like Debian, but don't use those; use Ubuntu or Manjaro). The AMD open-source one is great and everyone on AMD GPUs uses that. I've been running triple monitor, diagonally-aligned 1080p/1440p configurations for years on several distros and DEs with both Nvidia and AMD drivers.
(nvidia's proprietary drivers if it matters)
I doubt this will ever be fixed since it's an obscure hardware that's rarely used by other Linux users
https://github.com/typescript-eslint/typescript-eslint/issue...
It always seemed strange to me that people would rather use WSL than the real thing when Windows doesn't bring much advantage. What am I missing ?
Windows brings lots of advantage to some things (including interfacing with the large number of people who rely on people having software that works only or best on Windows; in anything other than very tech-focussed firms this probably includes your employer, and even in such firms it often includes your customers, which can matter a lot even in tech roles), and not switching between physical machines or rebooting between different tasks brings advantages.
How the world has changed!
Some people have made Juniper Pulse Client work in Linux, even a co-worker has posted some instructions. But I already have a setup where I start the VPN client in a Windows VM and tunnel through it.
I feel like any Linux solution would take a lot of time to setup and might not be as robust.
Another reason I still need Windows around is we only support S/MIME encryption in the Outlook client. Part of this is because of how our internal IT configures the cert, there is a way to make it work in the webmail but our IT guys have either opted out of that or not gotten around to it.
That's pretty much it though. I can happily use Linux for 99.99% of my time.
Using Linux without a reboot is an incredible convenience. Glossing over the value of proprietary software that only runs on Windows is narrow minded.
Edit: it does work, but it will sign you out from all M365 services which requires a lot of logins for nothing.
Shockingly, this is untrue if using KDE. Almost everything in it is better than a multi-billion-dollar company's monopolistic OS shell somehow, from the taskbar customization to the features (disable compositing, deep customization of effects and behavior, have windows remember size/position, etc.) to the file manager, Dolphin, which has split views, tabs, had a dark theme a dozen years ago, more file metadata to show optionally like date modified and size, thumbnails for even text files, terminal integration, and more (although technically that's an independent package available on any DE). The exceptions are how "smoothly" windows glide around the screen when dragged and that the Windows taskbar looks slightly better.
Quite ironic.
Visual Studio.
The other thing on my Windows VM is Affinity Photo/Designer (because GIMP is not a realistic Photoshop alternative).
I did some Googling yesterday and the last word on the matter is that Photo would cost $500k alone, which they couldn't see recuperating.[1]
[1]: https://forum.affinity.serif.com/index.php?/topic/626-affini...
Even something like Zoom worked like shit on Linux half the time. Or was missing features.
Audio/Video hardware had issues too. Something as simple as a webcam became this giant problem. Configuring mice and keyboards was a nightmare.
This is a lot to do with companies not supporting Linux and having to use community created reverse-engineered stuff, so it's not all Linux's fault, but at the same time, it just became a pain in the ass to maintain and fix constantly.
Also games, as much as Steam/Photon/Wine have improved, there are just some things that don't work.
So, I switched back to Windows, and even if I prefer linux, I just can't have it as my daily driver. so WSL2 is great for me.
Ignorant they are, yet their ignorance is a bliss.
The answer, at least in my case, has been using Windows where I must and WSL for whatever I can.
Being able to use both at the same time. Being able to open windows apps, and have them use the linux filesystem and executables (like IDEs)
Getting that same quality of experience under VirtualBox was nightmarish. Longer boot times, shared clipboard/filesystems were always breaking, random stuff related to hardening made update difficult.
WSL, on the other hand, has been nothing but trouble.
EDIT: At least compared to WSL1. However WSL2 also has some advantages in that it can reclaim unused memory and suspend the VM when not in use.
Which one? Secondary? And the primary does not work at all?
a) It comes default with some network binding magic (ok, just configuration) that makes your WSL env almost actually behave like localhost. I know you can configure this yourself, but it's nice out of the box. (on the other hand, sometimes is this exactly the opposite of what you want...)
b) My main machine is a bit RAM constrained, and WSL2 will "magically" reclaim RAM when I close the consoles (unless I left something running...). Once again, not the biggest win, especially if you spec'd out your machine to run VMs, but still nice.
I think WSL2's biggest wins are not for 'full out development'. But it's nice when you need want to jump in and poke at something quickly in Linux land. The startup time for the console/VM is fast enough (~1-2 seconds), and the cleanup is good enough I can quickly jump between, without having a VM actually hanging around all the time.
I'm sure the file system integration is useful for some usecases... classic one would be if someone emails you data files or something. You download in your browser in Windows and then can access pretty seamlessly from WSL.
I think I would summarize WSL's advantages as being a bunch of little quality of life advantages that are very much suited for Windows dominant workflows that periodically jump into Linux.
There are all sorts of other disadvantages though - I would not recommend anyone who has a comfortable VM based workflow to ditch for WSL. An example of an uncomfortably stupid rough edge would be periodically time-desyncing: https://github.com/microsoft/WSL/issues/4149 . I shit you not, my workaround is to manually adjust my linux time forward and back with `sudo date --set "${INCREMENT} seconds" until it gets close enough that OAuth doesn't shit itself.
- WSL1 shares the same network interfaces and addresses as the host, no proxying like WSL2
- Significantly less RAM usage
- No time sync bug
I use WSL2 for some docker based projects.
There are some issues still: GUI apps are still a pain to set up (but they're fixing this), there are some networking issues (e.g., accessing servers running on Linux), file path issues on some apps (like I guess git here), etc. I never personally experienced any of the git issues cited, and I use it regularly from the Ubuntu command line. Overall, I very highly recommend WSL2 now, Microsoft hit a home run with VSCode with devs and IMO WSL2 is turning out into another.
I'm what is called a "vacataire", which means I'm also not in the position of asking the school IT departement to enable stuff on the computers for the classes…
Likewise for WSL2.
I hope modern computers with a capable processor are all shipped with virtualization enable at firmware level, because Hyper-V can be used for tons of things in recent Windows.
Note that this benefit applies to the deprecated WSL 1 only, WSL2 actually runs a VM underneath so it requires the same hoops that a VM would require.
Microsoft understood that they only care about having some kind of POSIX support, and nowadays being Linux compatible is more relevant than straight POSIX, as the BSDs and IllumniOS also found out with their compatibility layers.
Setup is much less hassle, startup is much faster (one or two seconds) and resource usage is much lower than running Linux in a VM.
Also little things like VScode (running as Windows UI application) automatically detecting WSL and setting itself up to connect to the WSL side. To do the same for a VM requires at least to configure the SSL ports on the VM.
With VSCode I can switch between working in WSL and windows easily, without needing a desktop GUI to write code in. There's no startup cost, I'm immediately in the correct environment for that project. I've found it very useful since it came out.
I'm open to suggestions but it simply seems crazy difficult to do this outside of Windows. WSL lets me jump into *nix quickly when I need it for whatever reason. I don't need a desktop machine. Why not just use WSL?
In some cases I need to test something that's Linux-only -- an idea or a GitHub project that just doesn't run on Windows -- and it's easier to jump into a WSL console than boot a VM. But on the other hand, I don't do that frequently enough to just keep a VM running all the time. (Plus there's VM idle RAM usage, and I can't use Hyper-V [which can reduce VM RAM] due to host performance concerns)
EPM prohibits us from creating virtual machines, but WSL2 is possible. So a lot of devs at our shop (at least the 5% or so who are using WIN) use this setup.
Personally - I do this on my private machine - I switched, because with the EPM software I wanted to separate my work machine from my private efforts, as I just do not like Accenture to be able to read all mails, read all files and install arbitrary software on a machine that I have private data on. Before we got acquired my employer allowed private use, we were admins on the machines and there was no spyware installed - so only using one machine for work and private stuff was feasible.
WSL2 is basically just a Linux VM, though (I think it actually uses Hyper-V containers which seem to occupy some weird space between Linux container and VMs)
I know this is not a solution, but the Librem laptops from Purism hold up for hours straight. I also used to run Windows on laptops for the same reason, but the obvious solution to this is to buy a laptop built with Linux in mind from the ground up, and now we have options available.
I don’t quite get why some developers seem hell bent on those kinds of hybrid development environments. Why not straight up Linux or macOS where he user-space is consistent at least?
Brad Silverberg: "drdos has problems running windows today, and I assume will have more problems in the future."
Jim Allchin: "You should make sure it has problems in the future. :-)"
I stopped developing on Windows after the Windows 8 fiasco and I don't see myself ever coming back.
Both Mac and Linux are faster, more convenient, and more solid in my experience.
I considered advising my son to buy a Surface for his school work and developing on WSL2, but I'm glad the M1 Mac came out with a much better cost/performance, so he got one. At least his git repos won't get corrupted.
P.S. You simply cannot make this stuff up: as I was typing this comment in Safari, my input field text became blurred just like that in an instant https://imgur.com/a/2Ae0QpZ