Skip to content

ruby 3.2.2 - Errno::ENAMETOOLONG in a Windows with LongPathsEnabled #482

@rellampec

Description

@rellampec

This issue doesn't happen with ruby 2.7.2 (also from Windows Installer).

uru 3.2.2
ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]

irb
  • So running on x64
Dir.glob("*/**/*")

# => <internal:dir>:ln:in `glob': Filename too long - frontends/webapp-frontend/src/features/featureMangement/features/featureTypes/components/FeatureTypeDraggableField/components/AreaConfiguration/components/AreaFilters/components/AreaFiltersDrawer/components/AreaByLocationPreview/hooks (Errno::ENAMETOOLONG)
  • None of the ruby installer repos (old or new) has any reported issue on this matter.

Windows has a registry entry, under the path Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem, called LongPathsEnabled to enabling support for file paths over 260 characters, that defaults to 0 , but that can be changed to 1. There is a very complete article in Microsoft Docs: Maximum Path Length Limitation.

There have been a couple of bugs reported in ruby-core:

And one fix has been merged: [Win32] long path name support [Bug #12551]#4505 (very insightful article of the author of the fix).

Based on all the above, the only thing required is to have this entry in the windows application manifest:

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

By using the Manifest Tool, it is possible to directly embed the manifest using a command line similar to the following as a post-build step (article: How to embed a manifest inside a C/C++ application)...

mt.exe -manifest MyApp.exe.manifest -outputresource:MyApp.exe;1

And it is also possible to extract the manifest from an executable.

Obtaining the Manifest Tool via Windows SDK:

  1. Visiting SDK Downloads
  2. After using one of the installers.

Extracting the manifest:

mkdir c:\ruby\tmp
cp c:\ruby\Ruby32-x64\bin\ruby.exe c:\ruby\tmp\ruby.exe
cd "C:\Program Files (x86)\Windows Kits\10\bin\10.0.28000.0\x64"
.\mt.exe "-inputresource:c:\ruby\tmp\ruby.exe;#1" -out:c:\ruby\tmp\ruby.exe.manifest

Manifest of the ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
    </application>
  </compatibility>
  <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"/>
    </dependentAssembly>
  </dependency>
  <file name="x64-ucrt-ruby320.dll"/>
</assembly>

Well, here I am completely lost. The manifest does contain the ws2:longPathAware entry set to true. So I am not sure what is missing here.

reg query HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
    LongPathsEnabled    REG_DWORD    0x1

Can someone please share any solution, hint to other problems, etc.?

Should I just try to install the ruby 3.3.X or 3.4.X versions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions