Is it normal to use bash on Windows to build Rust projects?

Dear Rustaceans,

Question to Rustaceans on Windows :slight_smile:
For building Rust projects on Windows, do you use bash on Windows for the purpose?
Or do you write a separate batch script for building projects?

Definitely not normal for me - if a project requires me to use Cygwin or WSL, I just won't use it. It's not worth the hassle.

6 Likes

It would be unusual but it does happen more often nowadays. Especially since it's now easy to run a bash script in powershell just by typing bash script.sh, assuming WSL is installed.

1 Like

Just today I had an issue at work where my rust project of ±60 KSLOC will run on cmd.exe but crashes on Git bash. I prefer to use Git Bash (cmd.exe is severely cripple as should be no secret by now) when I use Windows, but this is one case where bash vs cmd.exe actually mattered.

2 Likes

As far as I’m concerned, WSL support is not real Windows support. WSL is a great project, don’t get me wrong, but I don’t have it installed on any of my machines, nor do I plan to.

5 Likes

As a reminder, the best scripting language for quick'n'dirty automation of Rust projects is Rust: https://matklad.github.io/2018/01/03/make-your-own-make.html :slight_smile:

6 Likes

I used Linux exclusively since 1997, hardly knew what Windows was. Until I found I could most of what I want on Windows 10 under WSL with Debian installed. Finally Windows was a useful operating system.

So, for two years or more now I have done almost everything under WSL on Windows, be it node.js, C++, now Rust, Verilog, etc. Sometimes I forget this is not a Linux machine. Most of what I work on ends up deployed in embedded systems, in the cloud or in the browser.

This has all worked very well except when I find I need a real Linux/Unix kernel, for example I can't get core dumps under WSL.

I once tried to build a Rust project on the Windows side, as it were, for Windows. Trying to figure out how to get Openssl into the mix was taking too long, I gave up. I have no real need or desire to create Windows applications so that was that.

1 Like

This. It is very important not for force users to install and use WSL to access some Rust features under Windows.

That being said, regarding the poll in the OP, I'm in a situation very similar to @ZiCog's: although I've always had windows systems around; the only time I ever feel truly free and flexible is within a linux shell. That's why it's only when Windows presented WSL that I started using Windows as the main system for my following machines. I get to have 95% of the nice Linux features (with a slower filesystem, truth be said), and the windows "window manager" (needed mainly for some games).

The shell interaction with cargo is done through WSL (except for cargo +nightly doc --open), and the IDE is VSCodium with the awesome rust-analyzer, so quite a bit of a hybrid interaction there :sweat_smile:

2 Likes

I develop in Windows, and I only use WSL when it's unavoidable, for example for implementing signals for a daemon or testing my program in Linux.

2 Likes

Have not used Windows for dev work since 2004 but then cygwin worked just fine, painless installation, I suspect WSL still uses \ for paths, argh. Plus it's nice to get a lot of normal Unix/Linux tools via cygwin so I would install that day one.

1 Like

No, WSL is a full Linux running in some variant of virtualization. It's way more compatible than cygwin, just apt-get your regular Linux tools (if you're using Ubuntu or Debian in it).

Indeed:
wsl
Bash in WSL is exactly as it is in Linux because that's what it is.

I've even managed to write a small Rust program that uses the mpv crate to play video from inside WSL to an X server I ran directly on Windows.

Also, the prebuilt Linux binary for CEF (aka Chromium) works with that X server.

I stand corrected, I have not used WSL. As long as you get POSIX shells, I'm fine. fish, even better.

My laptop is old and came with Windows 7 that does not have WSL. So if a project requires Cygwin/WSL I look for an alternative.

It could be just me, but WSL works really well except for Rust toolchain :frowning:
On WSL I always see strange errors around incremantal compilation (Error finalizing incremental compilation session directory). For a few times, surprisingly, merely running cargo build caused BSoD.

To be clear, there is no actual Linux kernel under the WSL. It is an Linux compatible API/ABI on top of Windows. Think of it like running Linux programs on BSD via whatever their adapter is called.

This works very well most of the time. As I said, I sometimes forget I'm not using a Linux box. I have yet to see any problems with Cargo/Rust under WSL.

Where it falls down is when you expect to get core dumps or use profilers or whatever that rely on actual Linux kernel functionality. Luckily not a frequent occurrence for me.

1 Like

That was WSL 1. WSL 2 uses virtualization for running the real kernel.

More information here

The only difference to a Linux machine I've seen so far is when accessing the Windows drives. They have some limitations, mostly due to the differences between NTFS and ext4 concerning permissions and case sensitivity.

2 Likes

At this point I should reiterate what steveklabnik said. Having WSL support is not true Windows support and most Windows developers would not expect to have to use it. So in that sense it isn't "normal" to use bash on Windows to build Rust projects.

However, developers with a Linux background do prefer using WSL for obvious reasons.

4 Likes

I use cmder as my terminal emulator of choice on Windows (which I don't use often). So yes, it's bash on Windows. But it's not PowerShell or WSL, so I don't really know what the poll is asking.