Skip to content

Conversation

@gavindidrichsen
Copy link
Contributor

@gavindidrichsen gavindidrichsen commented Dec 2, 2025

Summary

Fixes Windows long path issue where module extraction fails with Errno::ENAMETOOLONG when paths exceed 260 characters. The root cause: Ruby's Dir[] glob does not respect the Windows LongPathsEnabled registry setting.

For more information see BOLT-109

PLEASE can you do both a 5.0.5 and a 6.0.1 release fix?

Problem

When extracting modules with deep directory structures, Dir[] in root_dir method fails on Windows even with long paths enabled:

pry> Dir["#{@tmpdir}/**/metadata.json"].sort_by(&:length)[0]
Errno::ENAMETOOLONG: Filename too long - C:/Users/.../DSC_IEEnhancedSecurityConfiguration/en-US
# Path length: 263 characters (exceeds 260-char MAX_PATH limit)

This occurs despite LongPathsEnabled registry key being set to 1.

Solution

Replace Dir[] with Find.find, which properly respects Windows long path settings:

# Before
metadata_file = Dir["#{@tmpdir}/**/metadata.json"].sort_by(&:length)[0]

# After  
Find.find(@tmpdir) do |path|
  if File.basename(path) == 'metadata.json'
    # Find shortest path, same as original behavior
  end
end

Verification

Environment: Windows Server 2022, Ruby 3.2.5

Before (FAILS):

> bundle exec r10k puppetfile install
ERROR -> Module computermanagementdsc failed to synchronize due to Filename too long

After (SUCCESS):

> bundle exec r10k puppetfile install
# Success - 263-character paths created without error

Test Results

  • 202/203 tests pass
  • 1 pre-existing failure (also fails on main branch - unrelated to this PR)

Impact

  • Fixes module installation failures on Windows with deep directory structures
  • Affects Bolt 4.0.0+ users (regressed from Bolt 3.30.0 behavior)
  • No functional changes on Linux/macOS
  • Maintains backward compatibility

The Dir fails to respect the LongPath, which is enabled on the underlying windows system.  This Find equivalent logic, however, does work and is respected.

Signed-off-by: Gavin Didrichsen <gavin.didrichsen@gmail.com>
@gavindidrichsen gavindidrichsen force-pushed the bolt_109_fix_windows_longpath branch from 46818f6 to f800902 Compare December 2, 2025 02:37
@gavindidrichsen gavindidrichsen marked this pull request as ready for review December 2, 2025 02:56
@gavindidrichsen gavindidrichsen requested review from a team and bastelfreak as code owners December 2, 2025 02:56
@malikparvez malikparvez merged commit b4432ce into main Dec 11, 2025
1 of 5 checks passed
@malikparvez malikparvez deleted the bolt_109_fix_windows_longpath branch December 11, 2025 06:51
@bastelfreak
Copy link
Collaborator

Hey. I assume you are going to release this soonish. Would it be possible that you take a look at https://github.com/puppetlabs/forge-ruby/pulls/bastelfreak before doing a release?

@span786 span786 added the bug label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants