Issue #14631 has been updated by preetpalS (Preetpal Sohal).


Feel free to close this issue.

----------------------------------------
Bug #14631: Add support for long paths in Windows 10 when support is enabled in the OS
https://bugs.ruby-lang.org/issues/14631#change-71221

* Author: preetpalS (Preetpal Sohal)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x64-mingw32]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
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):

~~~ ruby

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):

~~~ python

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)))
~~~





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>