Project

General

Profile

Bug #14631

Add support for long paths in Windows 10 when support is enabled in the OS

Added by preetpalS (Preetpal Sohal) 4 months ago. Updated 4 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0p0 (2017-12-25 revision 61468) [x64-mingw32]
[ruby-core:86298]

Description

In newer builds of Windows 10, you can remove the limitations on path length (see: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/).

Currently the following Ruby script fails to create a directory with a really long path (fails at when i = 65):


require 'fileutils'

DIRPATH = "#{Dir.pwd}/ruby_long_path_stress_test"
Dir.mkdir(DIRPATH)
path_string = DIRPATH

begin
  999.times do |i|
    path_string += "/#{i}"
    Dir.mkdir(path_string)
  end
  puts "Was able to create directory (of length: #{path_string.length}): #{path_string}"
rescue => e
  puts e
ensure
  FileUtils.rmtree(DIRPATH)
end

Python (Python 3.6.2 - 64 bit) on Windows does not face this limitation (it can create a path of length 3953):


import os
import shutil

DIR = os.getcwd()

i = 1
pathToCreate = os.path.join(DIR, "python_long_path_stress_test")
while i < 1000:
  try:
    i = i + 1
    pathToCreate = os.path.join(pathToCreate, str(i))
    os.makedirs(pathToCreate)
  except:
    print("Failed to create folder:")
    print(len(os.path.abspath(pathToCreate)))
    exit(1)

print("Could create path of size:")
print(len(os.path.abspath(pathToCreate)))

Related issues

Is duplicate of Ruby trunk - Bug #12551: Exception accessing file with long path on windowsAssigned

History

#1 Updated by nobu (Nobuyoshi Nakada) 4 months ago

  • Is duplicate of Bug #12551: Exception accessing file with long path on windows added

#2 [ruby-core:86303] Updated by preetpalS (Preetpal Sohal) 4 months ago

Feel free to close this issue.

Also available in: Atom PDF