Project

General

Profile

Actions

Bug #14631

closed

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

Added by preetpalS (Preetpal Sohal) over 6 years ago. Updated about 5 years ago.

Status:
Closed
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 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #12551: Exception accessing file with long path on windowsClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0