Skip to content

Commit

Permalink
Enable ruby to support path length >260 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
larskanis committed Jun 11, 2021
1 parent 6073275 commit 829ab9d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ jobs:
echo.%GIT_REF_TAG% | findstr /C:"%target_ruby%">nul || (echo stop build not required for release & (exit 1))
)
- name: enable long paths on OS level
shell: powershell
# https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell
run: New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

- name: ensure bundler is installed on the build ruby
run: gem install bundler --conservative --no-doc

Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ init:
- IF DEFINED DEPLOY_TAG (
echo.%DEPLOY_TAG% | findstr /C:"%target_ruby%">nul || (echo stop build not required for release & (exit 1))
)
# enable long paths on OS level:
# https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell
- powershell New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

install:
# Avoid repo.msys2.org since it's down currently
Expand Down
5 changes: 5 additions & 0 deletions recipes/sandbox/60-side-by-side-assembly.rake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ end.each do |destpath|
image = File.binread(t.prerequisites.first)
# The XML elements we want to add to the default MINGW manifest:
new = <<-EOT
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
<dependency>
<dependentAssembly>
<assemblyIdentity version="1.0.0.0" type="win32" name="ruby_builtin_dlls" />
Expand Down
30 changes: 30 additions & 0 deletions test/test_long_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#frozen_string_literal: true
require "minitest/autorun"
require "tmpdir"

class TestStdlib < Minitest::Test
LONG_PATH = Dir.mktmpdir("0123456789"*15)

def test_mkdir
n = File.join(LONG_PATH, "c"*150)
Dir.mkdir n
assert Dir.exist?(n)
assert_operator 260, :<, n.size
end

def test_file_rw
n = File.join(LONG_PATH, "d"*150)
File.write n, "abc"
assert_equal "abc", File.read(n)
assert File.exist?(n)
assert_operator 260, :<, n.size
end

def test_load
n = File.join(LONG_PATH, "e"*150 + ".rb")
File.write n, "def loaded_a; 41; end"
assert load(n)
assert_equal 41, loaded_a
assert_operator 260, :<, n.size
end
end

0 comments on commit 829ab9d

Please sign in to comment.