Skip to content
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

[Feature Request] Sys.iswsl() #36354

Open
mgautam98 opened this issue Jun 19, 2020 · 13 comments · May be fixed by #57069
Open

[Feature Request] Sys.iswsl() #36354

mgautam98 opened this issue Jun 19, 2020 · 13 comments · May be fixed by #57069

Comments

@mgautam98
Copy link
Contributor

mgautam98 commented Jun 19, 2020

Background:
I am doing a project where I need to open Host system browser. The WSL is causing some problems if I detect it as Linux so I need to detect if Host is WSL to fix it.

While I can do someting like this: microsoft/WSL#4071 It would be convenient if we could have a Sys.iswsl() in Julia.

I would like to work on it myself but I couldn't understand Sys module .

@yuyichao
Copy link
Contributor

Note that this would be different from all other Sys.is* since this would have to be a runtime detection. Whether having it or not, giving it such similar a name would be misleading.

@yuyichao
Copy link
Contributor

(It's more similar to detection of linux distribution)

@mgautam98
Copy link
Contributor Author

@yuyichao why this would be a runtime detection? How does exactly OS is detected in Julia please help me understand.

@yuyichao
Copy link
Contributor

why this would be a runtime detection

Because you are not running a different binary from the linux one.

How does exactly OS is detected in Julia please help me understand.

This has nothing to do with why it needs to be done at runtime. It has to be done at runtime simply because this is a runtime property. It is not known at compile time and it can't be stored in the code as a constant.

There's nothing special about OS detection in julia. In fact there is none. All what Sys.is* do is returning a constant.

@mgautam98
Copy link
Contributor Author

mgautam98 commented Jun 19, 2020

We can check the version/release of Linux during compile time which will tell us if its wsl ? see microsoft/WSL#4071 (comment)

@yuyichao
Copy link
Contributor

No that's the wrong thing to do, that cannot tell you if you are running at runtime.

Again, it isn't about how to do the detection, it's about when to do the detection. The detection must be done after you download the binary from https://julialang.org/downloads/ when you start julia. It cannot be done when generating the binary you download.

@yuyichao
Copy link
Contributor

In another word, you don't care about whether your julia is compiled on WSL (it's not). You care about if it is running on WSL. And that's different from every other Sys.is*. It's not a property of the OS/target (i.e. ABI) it's a property of the distribution.

@mgautam98
Copy link
Contributor Author

mgautam98 commented Jun 19, 2020

Okay thanks for clearing my confusion. I compile my Julia on wsl so I forgot that people download binaries 😄

@Keno
Copy link
Member

Keno commented Jun 19, 2020

I do think we need a WSL feature detection macro, since we will also need to start shipping WSL-specific CUDA binaries. We may want to rethink how Sys. works in general. E.g. there's also the FreeBSD linux emulation layer.

@yuyichao
Copy link
Contributor

I don't think any change to how Sys works is necessary. Adding this as runtime detection won't break anything. However, I do think there's currently an expectation that these are not runtime detection so I think a different name should be used for ones that are done at runtime to break that expectation.

@mgautam98
Copy link
Contributor Author

mgautam98 commented Jun 22, 2020

@yuyichao what should be its name? It will help since I want to work on it

@StefanKarpinski
Copy link
Member

Maybe something with the word "detect" in it to indicate that active runtime detection is required for this.

@imciner2
Copy link
Contributor

How about Sys.detectwsl?

Then in the future more runtime detection methods could be added for things like containers as Sys.detectcontainer, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants