# \`isfile\` lies?

**URL:** <https://discourse.julialang.org/t/isfile-lies/85693>\
**Category:** General Usage\
**Created:** [August 13, 2022, 3:35am UTC](https://discourse.julialang.org/t/isfile-lies/85693 "2022-08-13T03:35:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 3:35am UTC](https://discourse.julialang.org/t/isfile-lies/85693/1 "2022-08-13T03:35:06Z")

</div>

Why would this be?

```julia
julia> isfile("GrayWhale\\simulations\\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25\\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25.json")          
false                                                                             
                                                                          
shell> ls -al "GrayWhale\\simulations\\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25\\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25.json"           
-rw-r--r-- 1 pkonl 197609 24917 Aug 12 10:43 'GrayWhale\simulations\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25.json'                                                                 
                                                                                  
shell> 

```

On Windows 10.

The `open` call also fails.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 13, 2022, 5:25am UTC](https://discourse.julialang.org/t/isfile-lies/85693/2 "2022-08-13T05:25:32Z")

</div>

What does `readdir(GrayWhale\\simulations)` return?

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [August 13, 2022, 6:58am UTC](https://discourse.julialang.org/t/isfile-lies/85693/3 "2022-08-13T06:58:35Z")

</div>

Could it be windows “powershell long filename issue”?

> **[Maximum Path Length Limitation - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell)**
>
> Maximum path length limitation.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 2:51pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/4 "2022-08-13T14:51:55Z")

</div>

```julia
julia> readdir("GrayWhale/simulations/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25")                                                                    
3-element Vector{String}:                                                                            
 "gw_fs_fluid_damping=1_forcing_t" ⋯ 37 bytes ⋯ "8_neigvs=2200_sweep=full25.json"                    
 "gw_fs_fluid_damping=1_forcing_t" ⋯ 36 bytes ⋯ "=8_neigvs=2200_sweep=full25.log"                    
 "results"                                                                                           
                                                                                                     
julia> 

```

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 3:00pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/5 "2022-08-13T15:00:40Z")

</div>

It would appear that Windows 10 has a limit on the length of the name of each individual file of 92 characters (plus extension). That is based purely on experimentation, I couldn’t find any documentation.  
The “cc…cc” file name is of acceptable length, the others are too long.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/a/2a37b34bb84e0e6b4b9d237970791cbd5242e904.png)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 13, 2022, 3:15pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/6 "2022-08-13T15:15:33Z")

</div>

> [@PetrKryslUCSD](#):
>
> ```julia
> julia> isfile("GrayWhale\\simulations\\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25\\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25.json")          
> false  
> 
> ```

This filename is 216 characters, which is starting to get close to the [260-character limit](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry) on pathnames in the Win32 API. Maybe something internally is expanding your relative path to an absolute path or a realpath (e.g. expanding symlinks) and is hitting that limitation.

`isfile(path)` just calls `isfile(stat(path))`, and `stat(path)` calls [`uv_fs_stat` from libuv](https://docs.libuv.org/en/v1.x/fs.html#c.uv_fs_stat). What does `stat` return on this path? If that’s not working, it may be a limitation of libuv.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 3:25pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/7 "2022-08-13T15:25:55Z")

</div>

It appears to be an OS limitation on the length of the individual file path component (those 92 characters).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 13, 2022, 3:30pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/8 "2022-08-13T15:30:47Z")

</div>

I’ve never heard of such a limit on individual files in Windows. The only limit I can find mentioned anywhere online is on total path lengths. It’s more plausible to me that if your file length is sufficiently long, then you are hitting the `MAXPATH` limit.

To test this, try moving the file into a folder with a shorter name.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 4:31pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/9 "2022-08-13T16:31:33Z")

</div>

You may be right, it could be that I was not able to make the individual file name longer  
because the file explorer counted all the characters in the absolute path. Which means that the relative path  
length was immaterial, because the system always used the limit on the absolute path.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [August 13, 2022, 4:31pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/10 "2022-08-13T16:31:50Z")

</div>

> **[Naming Files, Paths, and Namespaces - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN)**
>
> All file systems supported by Windows use the concept of files and directories to access data stored on a disk or device.

Does prepending `\\?\` to the path work?

Also describes how to disable the path check altogether on Windows 10/11.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 4:37pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/11 "2022-08-13T16:37:48Z")

</div>

```julia
julia> isfile("C:/Users/pkonl/Documents/00WIP/BoneShaker.jl/GrayWhale/simulations/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=fu25.log")                            
false                                                                                                
                                                                                                     
julia> length("C:/Users/pkonl/Documents/00WIP/BoneShaker.jl/GrayWhale/simulations/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=fu25.log")                            
258  
julia> isfile("\\\\?\\C:/Users/pkonl/Documents/00WIP/BoneShaker.jl/GrayWhale/simulations/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25/gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=fu25.log")                     
false  

```

I think that did not work.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [August 13, 2022, 4:38pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/12 "2022-08-13T16:38:47Z")

</div>

I don’t think you can mix slash directions.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 4:40pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/13 "2022-08-13T16:40:20Z")

</div>

Good point, still no cigar.

```julia
julia> isfile(raw"\\?\C:\Users\pkonl\Documents\00WIP\BoneShaker.jl\GrayWhale\simulations\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=fu25.log")                     
false  

```

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [August 13, 2022, 4:40pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/14 "2022-08-13T16:40:45Z")

</div>

Ah, sorry.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [August 13, 2022, 5:14pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/15 "2022-08-13T17:14:10Z")

</div>

I’ve seen it said many times on this forum that Julia aims for correctness…but I have not yet seen any such guarantees about truthfulness 😉

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 13, 2022, 7:15pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/16 "2022-08-13T19:15:54Z")

</div>

> [@PetrKryslUCSD](#):
>
> ```julia
> julia> isfile(raw"\\?\C:\Users\pkonl\Documents\00WIP\BoneShaker.jl\GrayWhale\simulations\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=full25\gw_fs_fluid_damping=1_forcing_type=approx_acoustic_pressure_meshnum=8_neigvs=2200_sweep=fu25.log")                     
> false  
> 
> ```

This path is 262 characters long, which is longer than the Windows `MAXPATH`.

640k and 260 characters ought to be enough for anybody, no?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 7:44pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/17 "2022-08-13T19:44:41Z")

</div>

But: notice the `\\?\`. That is expected to allow longer file paths. Oh well, not the first thing _not_ to work on Windows.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 13, 2022, 8:02pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/18 "2022-08-13T20:02:29Z")

</div>

By the way, I set `LongPathsEnabled` in the registry, to no avail.  
So now I am switching over to WSL 2. Windows is a best in class operating system? My foot!

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [August 13, 2022, 8:27pm UTC](https://discourse.julialang.org/t/isfile-lies/85693/19 "2022-08-13T20:27:24Z")

</div>

Oh, I think based on the documentation each application also needs to opt-in to supporting it.

But Julia itself seems to do that: [julia/julia-manifest.xml at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/contrib/windows/julia-manifest.xml)

libuv seems to as well

> <https://github.com/libuv/libuv/blob/master/uv_win_longpath.manifest>

---

<div class="post-metadata">

**Author:** ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)\
**Post date:** [August 15, 2022, 12:02am UTC](https://discourse.julialang.org/t/isfile-lies/85693/20 "2022-08-15T00:02:20Z")

</div>

> [@PetrKryslUCSD](#):
>
> By the way, I set `LongPathsEnabled` in the registry, to no avail.

Did you reboot the machine after doing so?

[Next page](https://discourse.julialang.org/t/isfile-lies/85693.md?page=2)
