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

Can't run flow in cmd when VS Code is open in Windows #6592

Closed
edele opened this issue Jul 11, 2018 · 14 comments
Closed

Can't run flow in cmd when VS Code is open in Windows #6592

edele opened this issue Jul 11, 2018 · 14 comments
Assignees

Comments

@edele
Copy link

edele commented Jul 11, 2018

The only difference is C and c drive letters:

flow is running on a different directory.
server_root: c:\Users\edele\flowtest, client_root: C:\Users\edele\flowtest

But I think paths are the same because Windows paths are case-insensitive.

server_root was created by Flow Language Support for VS Code. And the error is thrown whenever I run yarn run flow in cmd.exe to see full list of errors in a project.

Looks like the issue originates in vscode.TextDocument.uri.fsPath which "normalizes" drive letter to lowercase according to documentation: https://code.visualstudio.com/docs/extensionAPI/vscode-api#Uri

Still thinking on a possible solution.

  1. Should drive letter be forced to uppercase in Flow Language Support plugin because flow-bin uses uppercase?
  2. Should flow-bin change the way it decides if server_root and client_root are the same just for Windows?
  3. Am I missing something?

BTW. Just look at Microsoft nowadays. It's modern vibe feels so good. We have to consider Windows as a viable platform now.

@mrkev
Copy link
Contributor

mrkev commented Jul 12, 2018

After some quick skimming I didn't find where the uppercase C:\ comes from, but I found where the comparison is done:

if server_root <> client_root then begin

I guess the paths could be normalized to lowercase before comparing on windows? Not 100% sure it wouldn't have negative effects, but feel free to PR and ping me. For reference this PR does a check to discern platform: #6573

@codespitzer
Copy link

Has a solution/workaround been discovered for this issue?

@SergioMorchon
Copy link

Any news on this?

@ArmorDarks
Copy link

I guess the paths could be normalized to lowercase before comparing on windows? Not 100% sure it wouldn't have negative effects

that should be fine since on Windows paths aren't case sensitive, as it happens to be on Linux.

@edele
Copy link
Author

edele commented Oct 26, 2018

You can also run flow check instead as a workaround.

@Diggsey
Copy link

Diggsey commented Nov 3, 2018

Same issue here - windows 10.

@ArmorDarks
Copy link

Any chances to give that issue priority? That would so much improve dev experience on Windows.

The fix should be quite straightforward, as Windows paths are case insensitive, which means that on win platform all paths can be simply lowercased before comparison.

It's just the OCaml thing that stops from making a PR... Too stupid, sorry 😥

@edele
Copy link
Author

edele commented Jan 26, 2019

@ArmorDarks did you try running flow check instead of just flow?
It worked for me. If it wouldn't do it for you then could you tell me about your use case?

@ArmorDarks
Copy link

@edele Yeap, flow check works, thanks. But the issue with flow and flow status is still there.

@edele
Copy link
Author

edele commented Jan 26, 2019

@ArmorDarks which issue?

IIRC, the issue with running flow on win32 is that it tries to reuse existing flow server and it fails on path mismatch which is because of missing if (win32) {pathToMatch = pathToMatch.toLowerCase()}. But flow status will not try to reuse existing server.

So which issue are you talking about? 🙂

@ArmorDarks
Copy link

@edele you really force me to link you to your own comment, which exactly describes the issue #6592 (comment)

@edele
Copy link
Author

edele commented Jan 30, 2019

Some may find this helpful https://gist.github.com/edele/540b2ccb2e773e18e19a3e489336126b

You close VS Code, run kill-flow.bat and start anew with a fresh working state

@jeffvandyke
Copy link

Same issue at our place too, and using either https://github.com/jstwister/vscode-flow-ide or https://github.com/flowtype/flow-for-vscode both have this issue. It's highly annoying for wanting to run flow from any command line as an npm test command, and we can't be restarting VS Code whenever we want to run an npm script that involves flow. flow check takes 2 minutes to run on Windows thanks to small files, so we really need the regular flow to connect to the server.

Literally the only difference between server_root and client_root is the casing of d:\Repos vs D:\Repos Even the rest of the path preserves case.

@amankkg
Copy link

amankkg commented Apr 30, 2019

As a workaround, one could just pass PROJECT_ROOT manually, e.g. npx flow c:\some\path

@mroch mroch self-assigned this Sep 3, 2019
facebook-github-bot pushed a commit that referenced this issue Nov 12, 2020
Summary:
Windows file systems are case-insensitive (technically, case-preserving). VS Code sends all requests with a lowercase drive letter, like `file://c%3B/Users/...`, which gets decoded into `c:\Users\...`, but we normalize everything through `Path.make` which calls `Sys_utils.realpath` which (on Windows) calls `_fullpath`, which returns an uppercase drive letter.

we use filenames as keys all over, and obviously strings are case sensitive, so `c:\Users\...` and `C:\Users\...` end up being different internally.

so, to make sure everyone agrees, we'll uppercase the drive letter when we decode LSP URIs, and lowercase it when we generate URIs.

Fixes #6592

Pull Request resolved: #8531

Reviewed By: nmote

Differential Revision: D24893421 (cb32f21)

fbshipit-source-id: 39b1f34298bc719ddf80ee774338e492814e7b3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants