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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Windows Support - esy + dune config #199

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

bryphe
Copy link
Contributor

@bryphe bryphe commented Nov 24, 2018

Issue: reason-language-server isn't working for Windows configs. Uncommenting out the test is the quickest way to reproduce this.

There were several issues:

  • esy which gives a cygwin style path on Windows, so it's not what we want - for those paths, we then run them in the native shell, which will fail. I switched this to using esy where on Windows, which works as expected.
  • Path concatenation was not working in all cases, because it made assumptions about the form of the root directory - on Windows, a root directory could be something like E:\ or C:\, so added some detection there.

Still a bunch of things to fix - I'll leave comments for some open issues.

With my hacks in place, it's feeling pretty nice in Oni on Windows 馃帀
image
image

@@ -130,32 +130,42 @@ let detect = (rootPath, bsconfig) => {
let getEsyCompiledBase = (root) => {
let env = Unix.environment()->Array.to_list;

switch(Utils.getEnvVar(~env, "cur__original_root"), Utils.getEnvVar(~env, "cur__target_dir")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the big diff here! I remove this first block that checks the environment for esy environment variables, so it impacted the indentation.

This caused problems specifically in our test environment - it would pick up the esy root/target for reason-language-server instead of the test case. The esy command-env --json strategy seems more reliable, so I just deferred to that. @anmonteiro - let me know if I missed something here!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryphe checking for the env var is there to support esy named sandboxes, i.e. having foo.json instead of esy.json and starting your editor with esy @foo code .. I use them pretty heavily personally and this is the only way we can support them right now.

I think this needs to stay there. Can you think of an alternative?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the details @anmonteiro - supporting sandboxes makes sense.

I believe the issue here is limited to our tests - when we run esy dune exec ExamplesTests, it picks up the cur__original_root and cur__target_dir from the root reason-language-server esy config - this causes problems w/ the test.

A couple possible options:

  • We might be able to clear out the cur__original_root/cur__target_dir environment via the setenv stanza in dune
  • Alternatively, we could set an environment variable that we're in a test environment, and skip the sandbox that way.

Still looking into this but let me know if you have ideas. I think it's crucial to have a test covering the esy+dune scenario here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the change, but as expected esy test fails... looking into it...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like esy wasn't being launched in the correct spot. I think we'll also have to run ExamplesTest.exe outside the esy sandbox, otherwise the environment gets polluted with cur__original_root/cur__target_dir

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think that makes sense. I'm glad the issue seems to be limited only to tests.

src/analyze/BuildSystem.re Outdated Show resolved Hide resolved
src/analyze/BuildSystem.re Outdated Show resolved Hide resolved
util/Infix.re Outdated Show resolved Hide resolved
@jaredly
Copy link
Owner

jaredly commented Nov 24, 2018

Awesome thanks for jumping into this!

@anmonteiro
Copy link
Collaborator

I went through the PR and I think there's still some important issues to address here, specifically the support for esy named sandboxes, which we'll lose if we keep the current approach.

Copy link
Owner

@jaredly jaredly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see @anmonteiro's concerns

@bryphe bryphe mentioned this pull request Dec 1, 2018
@saitonakamura
Copy link

May I bump this?

| (_, _) =>
switch (Commands.execResult("esy command-env --json")) {
switch (Commands.execResult(~cwd=root, "esy command-env --json")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this root doesn't exist anywhere...

let execFull = (~input=?, ~pwd=?, ~env=Unix.environment(), cmd) => {
let cmd =
if (Sys.os_type == "Win32") {
Printf.sprintf("\"%s\"", cmd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't use %S it might be more robust with space and other special char ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And use Sys.win32 ?

@Et7f3
Copy link
Contributor

Et7f3 commented Aug 11, 2019

I have tried to make it work on windows see: Et7f3@4681fb3.
When I wanted to open a PR I have seen this PR so I wanted to compare implementations.

One of the main difference:

  • which/where: where on windows search for all binaries. So if you have 2 ocaml in your PATH (that is my case) it will output both.
  • which/cygpath: cygpath with the option -w convert the result of which to windows path. which return only the first result and cygpath.

Also the native ocaml compiler use cygpath and it work fine see https://github.com/alainfrisch/flexdll/blob/5fde2bd70a088cd11271925aa6352fc29ec94291/reloc.ml#L230-L234 they use -m I have used -w 馃 the difference is / or \ both are supported on windows 馃し鈥嶁檪.

Thanks bryphe for https://github.com/jaredly/reason-language-server/pull/199/files#diff-39f5b0dce8e3aa4cb0c9d1ced2d6d55aR289-R290 :) I could remove my global OCAMLLIB variable.

esy named sandbox don't seem to work properly.

@jaredly
Copy link
Owner

jaredly commented Aug 11, 2019

@Et7f3 awesome, thanks for taking up the torch! Do you want to open up a new PR?

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 this pull request may close these issues.

None yet

5 participants