flow-upgrade not working under Windows

Created on 18 Aug 2017  路  10Comments  路  Source: facebook/flow

I've tried to run flow-upgrade under Windows 10 and it fails
capture

Then I tried to do it with Windows Ubuntu Bash and everything works. So it seems like it's only Windows specific problem.

easy Windows support help wanted

Most helpful comment

As a quick workaround for anyone who doesn't want to install Windows Ubuntu Bash, you can open the runCodemods.js file shown on the first line of the call stack and edit fs.mkdtempSync('/tmp/flow-upgrade-') to something like fs.mkdtempSync('C:/tmp/flow-upgrade-').
Then make sure the C:\tmp dir exists and run flow-upgrade again. Worked for me on Windows 7.

All 10 comments

As a quick workaround for anyone who doesn't want to install Windows Ubuntu Bash, you can open the runCodemods.js file shown on the first line of the call stack and edit fs.mkdtempSync('/tmp/flow-upgrade-') to something like fs.mkdtempSync('C:/tmp/flow-upgrade-').
Then make sure the C:\tmp dir exists and run flow-upgrade again. Worked for me on Windows 7.

@lll000111 my screenshot is from git bash ;) It's not working. As well as PowerShell

Okay... so this problem can be reproduced with this simple command (taken from the actual code) in a node.js console:

fs.mkdtempSync('/tmp/flow-upgrade-')

It is node.js doing it.

Looks like a node.js bug, not even their own example (given for the async. version of this function) works:

https://nodejs.org/dist/latest-v8.x/docs/api/fs.html#fs_fs_mkdtemp_prefix_options_callback

image

yep.

See the node.js issue I created referenced above - the absolute path on Windows gets translated to C:\tmp\... (when using bash).

Not a Flow issue, this issue should be closed - it's node or git-bash.

Reported in node.js issues as https://github.com/nodejs/node/issues/14960

Workaround

As @mjomble already said, but it does not require a code change. Just create a folder C:\tmp and try again and flow-upgrade will work.


PS: By the way, in my (already clean for Flow 0.53) code the command replaced ALL end-of-file newlines (and only those!) that in my project are Unix-style LF with CRLF, and it added () around a logical expression inside an if statement that already had them (now has two).

Can confirm, same issue occurring - @lll000111's workaround above resolved it.

I had all my line endings converted as well.

@lll000111 if anyone wants to make a PR of this and ping me, the fix seems simple. It seems to be just changing the line here: https://github.com/facebook/flow/blob/5aaf9b9177514c7ed0c2b65af7efff4fea5c5775/packages/flow-upgrade/src/codemods/runCodemods.js#L27

From fs.mkdtempSync('/tmp/flow-upgrade-'), to fs.mkdtempSync(path.join(os.tmpdir(), 'flow-upgrade-'),.

Busy with lots of other stuff so it's in the backlog for some time. Easy GitHub square though (:

@mrkev I'm new here, ran into the same problem. I wanted it working, and it was indeed an easy fix, so I put up a PR.

Perfect, thanks! Will attempt to merge soon (:

Was this page helpful?
0 / 5 - 0 ratings