Yarn: Document that Yarn currently doesn't work on Bash on Windows

Created on 11 Oct 2016  Â·  17Comments  Â·  Source: yarnpkg/yarn

I don't really think this is Yarn's responsibility to fix, but it should be noted it doesn't work on Ubuntu bash on Windows, where as npm cli does. The issue is down to uv_interface_addresses something a lot of packages are broken by. Again I'm am fairly sure this is a wontfix but it should be noted either way.

os-windows

Most helpful comment

For those on Bash on Windows wanting to try out yarn, there's a simple workaround.

Update these two files:
/usr/lib/node_modules/yarn/lib/util/network.js
/usr/lib/node_modules/yarn/lib-legacy/util/network.js

In both files, change line 13 to read const interfaces = {};

Haven't run into any other compatibility issues apart from that one.

All 17 comments

Yeah, known issue with WSL at the moment: https://github.com/Microsoft/BashOnWindows/issues/468.

Closing this out since it's an upstream issue. Thanks for reporting!

hi, can this be added - if it hasn't yet/ if applicable - somewhere in readme or docs that this is a known issue ? in a little way this would help people like me from spending their time going through the ubuntu package install process. thanks

Sure thing, let's repurpose this task to add a note to the docs.

https://github.com/yarnpkg/website/pull/129 hopefully my formatting is alright submitted from chrome on Android 😬

For those on Bash on Windows wanting to try out yarn, there's a simple workaround.

Update these two files:
/usr/lib/node_modules/yarn/lib/util/network.js
/usr/lib/node_modules/yarn/lib-legacy/util/network.js

In both files, change line 13 to read const interfaces = {};

Haven't run into any other compatibility issues apart from that one.

@mogest wonder if it is a good candidate for a PR upstream ? looking at the uservoice comments from WindowsBash team, they're working on it but no definite timeline. Otherwise there would Zero users from Windows on Ubuntu Bash. I know there's a Windows version but I'd prefer using the native bash. thanks

@rixrix A try/catch block could be wrapped around that line so that it defaults to {} if the os.networkInterfaces() call fails, but I can see why the yarn maintainers might want to wait for Microsoft to implement the call.

@mogest - Wow, I didn't realise that we just need to modify a single call site to get Yarn running in WSL. That's awesome!

This is the source for the code you mentioned: https://github.com/yarnpkg/yarn/blob/master/src/util/network.js#L9. It looks like the purpose of the code is to determine if the user is online, based on whether they have a non-localhost IP address. For Windows, we could probably call a Windows-specific API to check this.

This can also be done as a post install step, but I also agree it's kind of
hacky for Yarn to try catch for a module that's supposed to exist.

As a side note in the thread linked I believe there is an explanation on
how to patch your global modules to fix this for most dependencies.

On Oct 11, 2016 5:47 PM, "Roger Nesbitt" [email protected] wrote:

@rixrix https://github.com/rixrix A try/catch block could be wrapped
around that line so that it defaults to {} if the os.networkInterfaces()
call fails, but I can see why the yarn maintainers might want to wait for
Microsoft to implement the call.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/yarnpkg/yarn/issues/636#issuecomment-253056640, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABsC1tLEa3O9zFofGnufC20GjY-Ri1xQks5qzAPbgaJpZM4KT1bY
.

@Daniel15 Yeah, pretty neat eh!

Bash on Windows isn't Windows, so unfortunately there's no access to Windows calls. As far as anything that runs in Bash on Windows is concerned, it's running on Linux (albeit one that doesn't implement 100% of Linux features.)

By falling back to an empty list of interfaces, I get the warning:

warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.

but otherwise it continues to work fine, including performing network access.

Bash on Windows isn't Windows, so unfortunately there's no access to Windows calls

Oh yeah, true. Looks like ifconfig and ip addr list both fail, so we can't even use the hacky approach of parsing their output 😢

I wonder if we should just assume that the user is always online when running under Windows Subsystem for Linux. I assume there's a way we can detect that we're running in Ubuntu on Windows as opposed to 'vanilla' Ubuntu.

You could see whether os.networkInterfaces() throws 😉

I had been looking around for such a sign the user was on WSL for a previous project and couldn't find anything official.

Filed a separate task #753 specifically for this (avoiding os.networkInterfaces on WSL)

As an aside, I've been using WSL quite a bit recently, and even build the Yarn Debian/Ubuntu and CentOS package repository with it. Seems to work really well apart from issues like this one.

all / @mogest the work-around works perfectly, thanks. hopefully yarn stuff for me for a wee while. cheers

This was fixed a while back

Yarn is still freezing for me on 1/4 step. ifconfig works and os.networkInterfaces() return object. yarn version 1.13.0 from deb repo in Ubuntu on Windows 10 WSL.

Was this page helpful?
0 / 5 - 0 ratings