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

Flow does not find files behind a symbolic link directory path #4015

Open
lll000111 opened this issue May 24, 2017 · 14 comments
Open

Flow does not find files behind a symbolic link directory path #4015

lll000111 opened this issue May 24, 2017 · 14 comments

Comments

@lll000111
Copy link
Contributor

lll000111 commented May 24, 2017

Flow: 0.46
Platform: Windows 10 (git-bash)

TL;DR: Files in a symlinked directory are not found, Flow does not seem to follow symlinks at least on Windows.

Tiny test project: Test.zip

WARNING: The ZIP included the sym-linked directory as full directory! Remove Test/src/system/ and create a symlink with (on Windows) mklink /D system nodejs inside Test/src/. If you just unzip it and run Flow there are no errors - obviously.

I use a symbolic link to link to one of my three directories with platform-dependent code (nodejs, browser, react-native). They all have the exact same files and API, just the platform-dependent part of the implementation.

Then I created a symbolic link named system pointing to the directory with the platform-dependent files. Before that I had ./nodejs/someFile.js in all require('...') commands and used a build process to replace the "nodejs" with whatever platform the build was for.

So after switching to this much cleaner method (no code rewrites) Flow gives me a Required module not found error for each one of the imports that look similar to require('./system/storage-base.js'); (before it was require('./nodejs/storage-base.js'); in the src/ directory and "nodejs" replaced after build in the lib/ directory).

WebStorm has no problem with the symlink (just an aside).

I found #149 but that was closed by the author without giving a reason.

Also: #46 (comment)

And also #164 -- this sounds as if it should work when the Flow server is restarted and that only watching for changes is the issue, but I did restart flow.exe and it made no difference.

@torarnek
Copy link

torarnek commented Nov 1, 2017

Any progress on this?

This makes it hard to used linked modules with flow, e.g. yarn link.

@juancampa
Copy link

juancampa commented Nov 22, 2017

I can confirm flow fails to find a module that exists in node_module as a perfectly valid symlink created through yarn link. Node has no problem require-ing it.

@rvion
Copy link

rvion commented Jan 23, 2018

this turns out really painful to deal with in complex codebases

@dwwoelfel
Copy link

This will also prevent flow types from working in development for dependent packages in yarn workspaces.

@mjg17
Copy link

mjg17 commented Feb 2, 2018

I've just encountered this, in the context of using yarn link to work on an app and a related module.

It would be really nice if flow could follow yarn link links.

@mjg17
Copy link

mjg17 commented Feb 2, 2018

It turns out that the workaround in #164 works for me (on Linux) - stop and restart the flow server after setting up the yarn link.

Ideally flow would notice without a restart, but at least there is a workaround.

@willisplummer
Copy link

Stopping and starting flow resolved this issue for me

@andiwinata
Copy link

using flow check works for me

@lll000111
Copy link
Contributor Author

lll000111 commented Jun 21, 2018

@andiwinata Why do you post a comment if you don't have this issue??? The 2nd guy who tells us that they don't have a problem. Did you test THIS specific problem? Did you check with the test project included in the initial comment (and follow the instructions to reproduce!)?

@andiwinata
Copy link

hi @lll000111 , my bad, sorry about that.

I was searching for issue about yarn link and this issue popped up, and saw the comment about restarting flow fixed the issue - which is true. Thus I commented using flow check will work too since it seems using new flow server every time it runs.

Again sorry for hijacking your issue

@lll000111
Copy link
Contributor Author

@andiwinata

the comment about restarting flow fixed the issue - which is true

THIS issue, or your issue? As I said, did you try to reproduce this issue?

@vladp
Copy link

vladp commented Aug 3, 2018

Does not work for me either
Windows 10/


  "flow-bin": "^0.77.0",
    "flow-typed": "^2.5.1",

The .flowconfig
module.name_mapper='^web_common' ->'<PROJECT_ROOT>/csr-cra/src/wc.src'

cannot process

import {something} from 'web_common/Someting';

The symlink on windows is
<SYMLINKD> wc.src [..\..\..\web.common\wc.src\]

under src/

(I also tried
module.name_mapper='^web_common' ->'<PROJECT_ROOT>/src/wc.src' )

@vladp
Copy link

vladp commented Aug 3, 2018

I have gotten this work on windows.

The [include] option in the .flowconfig has to point to the physical directory associated with the given symlinked directory
Notice, now in my updated .flowconfig the directory in the the [include] option points to the actuall (relative, but not symlinked) location.



[ignore]

.*/node_modules/.*
.*/build/.*
config-overrides.js
.*/src/registerServiceWorker.js
.*/src/index.js

.*/config-overrides.js


[include]


../../web.common



[libs]
flow-typed

[lints]

[options]

all=true

module.system.node.resolve_dirname=node_modules
module.name_mapper='^react-native' ->'node_modules/react-native-web'
module.name_mapper='^web_common' ->'src/wc.src'

esproposal.decorators=ignore
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

suppress_type=$FlowIssue
suppress_type=$FlowFixMe



[strict]



@nate-whil
Copy link

@vladp that was my issue as well https://flow.org/en/docs/config/include/

mergify bot pushed a commit to pinterest/gestalt that referenced this issue Aug 28, 2020
Enable flow types on our Gestalt docs. Improves type safety and caught a couple of actual issues.

We previously did not enable these because of facebook/flow#4015. It does mean we might have to restart the docs server when we make a change to Gestalt.

## Test Plan

`yarn flow` passes + checks the docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests