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

Regression (Linux): FileSystemWatcher.onDidCreate doesn't fire event when watched file is a symlink #142008

Closed
karrtikr opened this issue Feb 2, 2022 · 13 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@karrtikr
Copy link
Contributor

karrtikr commented Feb 2, 2022

Does this issue occur when all extensions are disabled?: Yes

Version: 1.63.2 (user setup)
OS: Ubuntu

Steps to Reproduce:

  1. Open a workspace folder in extension host while debugging your extension .
  2. Use the following code in your extension.
const globPatern = new RelativePattern(vscode.workspace.workspaceFolders[0].uri.fsPath, '*/bin/python');
const fsWatcher = this.workspaceService.createFileSystemWatcher(globPatern);
fsWatcher.onDidCreate((e) => {
    console.log('Old code create', e.fsPath);
});
  1. Use command python3 -m virtualenv .virtualenv to create a virtual environment. Notice Old code create... is not printed.
@bpasero
Copy link
Member

bpasero commented Feb 2, 2022

We no longer automatically follow symbolic links for file watching for performance reasons. See https://code.visualstudio.com/updates/v1_61#_file-watching-changes

@bpasero bpasero added the file-watcher File watcher label Feb 2, 2022
@karrtikr
Copy link
Contributor Author

karrtikr commented Feb 2, 2022

I understand that symlinks (link's path) won't be followed, but does this mean symlink files themselves cannot be watched for changes? For eg. in this case we just wanted to look for the python file (symlink), and not follow the symlink (for changes in link's path).

@karrtikr
Copy link
Contributor Author

karrtikr commented Feb 2, 2022

If symlink file type are indeed no longer supported, unfortunately workaround mentioned to use files.watcherInclude doesn't work for us, as that would mean we have to configure this setting explicitly for all our users. Will it possible to configure supporting symlinks via the API itself?

@bpasero
Copy link
Member

bpasero commented Feb 2, 2022

Extensions are now actually able to provide default settings, so maybe that is an option? See https://code.visualstudio.com/updates/v1_63#_configuration-defaults-overrides

Let me reopen this issue and treat it as feature request, I think maybe given the new file watching support for out-of-workspace folders (see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_64.md#vscodeworkspacecreatefilesystemwatcher-now-supports-any-path) we could argue that an explicitly watched in-workspace path will be checked for being a symlink or not and then supported.

@bpasero bpasero reopened this Feb 2, 2022
@bpasero bpasero added api feature-request Request for new features or functionality and removed *as-designed Described behavior is as designed labels Feb 2, 2022
@bpasero bpasero added this to the Backlog milestone Feb 2, 2022
@bpasero bpasero removed their assignment Feb 2, 2022
@bpasero bpasero changed the title Regression (Linux): FileSystemWatcher.onDidCreate doesn't fire event when watched file is a symlink Allow createFileSystemWatcher to watch symbolic links inside workspace Feb 2, 2022
@karrtikr
Copy link
Contributor Author

karrtikr commented Feb 2, 2022

Thanks, just to clarify, we want to be able to monitor symlink creation. This is crucial for us as Python environments across all platforms contain such symlinks and detection logic won't work otherwise. Without this we won't be able to use the VSCode file watcher in the Python extension even though we really want to, and will have to keep relying on other libraries as we have been doing.

Extensions are now actually able to provide default settings, so maybe that is an option? See https://code.visualstudio.com/updates/v1_63#_configuration-defaults-overrides

That does bring us closer but paths to watch can be dynamic and depends on discovery logic, so specifying a set of fixed paths in package.json does not always work for us.

@bpasero
Copy link
Member

bpasero commented Feb 2, 2022

Hm, ok then maybe I misunderstood. To my knowledge, the creation of a symlink should actually be reported as a file change event, though you would not receive any file events for changes to the target of that link.

To clarify: you are only interested in a symlink getting created or deleted but do not require the watcher to follow the symlink and watch for changes on the target?

@bpasero bpasero changed the title Allow createFileSystemWatcher to watch symbolic links inside workspace Regression (Linux): FileSystemWatcher.onDidCreate doesn't fire event when watched file is a symlink Feb 2, 2022
@bpasero bpasero self-assigned this Feb 2, 2022
@bpasero bpasero added info-needed Issue requires more information from poster and removed feature-request Request for new features or functionality api file-watcher File watcher labels Feb 2, 2022
@bpasero bpasero removed this from the Backlog milestone Feb 2, 2022
@karrtikr
Copy link
Contributor Author

karrtikr commented Feb 2, 2022

Yes that's correct.

To my knowledge, the creation of a symlink should actually be reported as a file change event, though you would not receive any file events for changes to the target of that link.

Not sure if it's important but I was using WSL.

@bpasero
Copy link
Member

bpasero commented Feb 2, 2022

Not sure if it's important but I was using WSL.

It is important, for WSL specifically we switch to a polling only solution because file events are not reliable. @aeschli has the details when we do that, I think it depends on WSL1 vs WSL2 usage.

Can you try to reproduce without WSL?

@aeschli
Copy link
Contributor

aeschli commented Feb 3, 2022

To have polling in WSL, you need to be in a WSL1 distro and have set the setting "remote.WSL.fileWatcher.polling": true (it's off by default). The WSL log (Remote-WSL: Show Log) would contain some message about polling.

@bpasero bpasero added this to the February 2022 milestone Feb 3, 2022
@bpasero bpasero added file-watcher File watcher info-needed Issue requires more information from poster and removed info-needed Issue requires more information from poster file-watcher File watcher labels Feb 4, 2022
@bpasero bpasero removed this from the February 2022 milestone Feb 4, 2022
@bpasero
Copy link
Member

bpasero commented Feb 4, 2022

I cannot reproduce, either with our polling file watcher or with the normal one. Steps:

  • Linux Ubuntu
  • open a folder in VSCode
  • from a terminal create symlink via ln -s <source> <target>
  • observer how the link appears in explorer

Works for me both with a file link and a folder link.

@bpasero
Copy link
Member

bpasero commented Feb 4, 2022

Could be a WSL only problem that only appears inside WSL and then this should be a bug report for the WSL team.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants
@bpasero @weinand @aeschli @karrtikr and others