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

Ripgrep not working in OneDrive folders using Files On Demand #705

Closed
roblourens opened this issue Dec 4, 2017 · 11 comments
Closed

Ripgrep not working in OneDrive folders using Files On Demand #705

roblourens opened this issue Dec 4, 2017 · 11 comments

Comments

@roblourens
Copy link
Contributor

Ref: microsoft/vscode#35433

Files On Demand is a new OneDrive feature that only downloads files to the local disk when needed. It has caused some issues in Node/Electron land - nodejs/node#12737, microsoft/vscode#27285.

When running ripgrep in a folder with this feature enabled, I just get Access is denied. (os error 5) immediately. Running with --debug doesn't produce any clues. I will investigate if you can point me in the right place to start looking?

@BurntSushi
Copy link
Owner

BurntSushi commented Dec 4, 2017 via email

@roblourens
Copy link
Contributor Author

I get the same error with --no-mmap. Here is a fix in libuv for this onedrive feature: https://github.com/libuv/libuv/pull/1522/files, if this is a similar problem, it's probably in Rust's fs.

Repro steps are basically

  • Install the latest updates for Windows and OneDrive
  • Open OneDrive settings, enable "Files On-Demand"
  • Wait a couple minutes for OneDrive to do it's thing
  • Invoke ripgrep in a OneDrive folder

@BurntSushi
Copy link
Owner

Thanks!

cc @retep998 Do you have any insight on this with respect to std?

@roblourens
Copy link
Contributor Author

Filed rust-lang/rust#46484

@roblourens
Copy link
Contributor Author

Since there isn't much progress on the upstream issue, I'm trying to work around it in the ripgrep build for vscode. Would you be interested in a PR? The workaround is fairly simple, just need to check the file_attributes of a directory for the reparse point and directory flags: https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117.aspx. And it needs to be done in a few places in the walkdir and ripgrep repos.

@BurntSushi
Copy link
Owner

@roblourens Sorry for the late response, but yes, I would definitely be interested in a patch to ripgrep proper. If I had more Windows expertise, then I'd be happy to push this through upstream too, but I just don't have the bandwidth at the moment, so I'm happy to work around it.

@BurntSushi
Copy link
Owner

@roblourens I am working on a fix to this in walkdir and ignore. I may have convinced someone to fix it in std as well, but even if the latter were fixed and merged tonight, ripgrep wouldn't see it for months.

@roblourens
Copy link
Contributor Author

Awesome! Sorry I never delivered on my drive-by PR offer, it's been on my list but I was too busy in January.

@BurntSushi
Copy link
Owner

@roblourens No worries! The Windows side of things is pretty straight-forward, but fixing the code itself is a little gnarly!

BurntSushi added a commit to BurntSushi/walkdir that referenced this issue Feb 2, 2018
This commit fixes a bug on Windows where walkdir refused to traverse
directories that resided on OneDrive via its "file on demand" strategy.
The specific bug is that Rust's standard library treats a reparse point
(which is what OneDrive uses) as distinct from a file or directory, which
wreaks havoc on any code that uses FileType::{is_file, is_dir}. We fix
this by checking the directory status of a file by looking only at whether
its directory bit is set.

This bug was originally reported in ripgrep:
BurntSushi/ripgrep#705

It has also been filed upstream:
rust-lang/rust#46484

And has a pending fix:
rust-lang/rust#47956
@BurntSushi
Copy link
Owner

Got it! I manually tested the fix. I can search directories on OneDrive using ripgrep master.

@roblourens
Copy link
Contributor Author

roblourens commented Feb 6, 2018

This works great. Thanks! Will update in vscode ASAP.

BurntSushi added a commit that referenced this issue Feb 20, 2018
This commit fixes a bug where symlinks were always being followed on
Windows, even if the user did not request it. This only impacts the
parallel iterator.

This is a regression from the fallout of fixing #705.

Fixes #824
BurntSushi added a commit that referenced this issue Feb 21, 2018
This commit fixes a performance regression in Windows that resulted from
fallout from fixing #705. In particular, we introduced an additional
stat call for every single directory entry, which can be quite
disastrous for performance.

There is a corresponding companion PR that fixes the same bug in
walkdir: BurntSushi/walkdir#96

Fixes #820
BurntSushi added a commit that referenced this issue Feb 21, 2018
This commit fixes a performance regression in Windows that resulted from
fallout from fixing #705. In particular, we introduced an additional
stat call for every single directory entry, which can be quite
disastrous for performance.

There is a corresponding companion PR that fixes the same bug in
walkdir: BurntSushi/walkdir#96

Fixes #820
BurntSushi added a commit that referenced this issue Aug 22, 2018
This commit undoes a work-around for a bug in Rust's standard library
that prevented correct file type detection on Windows in OneDrive
directories. We remove the work-around because we are moving to a
latest-stable Rust version policy, which has included this fix for a while
now.

ref #705, rust-lang/rust#46484
BurntSushi added a commit that referenced this issue Aug 22, 2018
This commit undoes a work-around for a bug in Rust's standard library
that prevented correct file type detection on Windows in OneDrive
directories. We remove the work-around because we are moving to a
latest-stable Rust version policy, which has included this fix for a while
now.

ref #705, rust-lang/rust#46484
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

No branches or pull requests

2 participants