question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IFileSystem.fileExists returns false even when a file exists.

See original GitHub issue

This breaks conda and virtual environments

  • These environments are no longer listed as interpreters, hence absolutely nothing works for conda or virtual environments.

In master. I believe the logic of checking the file stat is incorrect. We’re checking if the file type == FIle when checking if a file exists. However fstat could indicate that its a symbolic link.

Not sure this is the issue, but likely. Either way still is incorrect.

I.e. I don’t think we should be comparing == File, we might want to check if !== Directory instead. I.e. allow other values except directory. I.e. its possible Unknown could be returned for a file (just as with symbolic links & others).

Proposed solution

  • If checking for a file, then ensure fstat !== direcrtory
  • If checking for a directory, then ensure fstat !== file

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Dec 4, 2019

The problem is we’re treating the FileType as an enum and comparing ===. However these are bit values and we need to use bitwise operations.

0reactions
ericsnowcurrentlycommented, Dec 4, 2019

Right. I have a fix for that. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does System.IO.File.Exists(string path) return false?
The Exists method returns false if any error occurs while trying to determine if the specified file exists. This can occur in situations...
Read more >
File.Exists(String) Method (System.IO) - Microsoft Learn
Determines whether the specified file exists. ... This method also returns false if path is null , an invalid path, or a zero-length...
Read more >
File.exists(filename) is not working properly my file name ...
The Exists method returns false if any error occurs while trying to determine if the specified file exists. This can occur in situations...
Read more >
FileSystemObject's FileExists function returns false for existing ...
Hi, my friends: Strange things happen when I use Scripting.FileSystemObject to read local files. For an existing file, sometimes FileExists returns true, ...
Read more >
An Empirical Study of Testing File-System ... - CiteSeerX
particular entry file exists (using the FileExists method of IFileSystem) and whether a metadata folder exists. (using the DirectoryExists method of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found