Skip to content

Conversation

@Saidbek
Copy link

@Saidbek Saidbek commented Jan 29, 2026

What is your fix for the problem, implemented in this PR?

Fixes #7681

Windows doesn't allow certain characters in filenames (e.g., colons) that are valid on Unix. When gems contain files with these characters, installation fails on Windows with cryptic Errno::EINVAL errors.

This PR adds validation and directs users to report issues to gem authors instead.

  • Add InvalidFileNameError with user-friendly messages
  • Validate filenames during gem extraction on Windows
  • Warn developers when building gems with invalid filenames

Make sure the following tasks are checked

Add validation and clear error messages for gems with filenames containing
invalid Windows characters (e.g., colons), directing users to report issues
to gem authors instead of RubyGems.
@Saidbek Saidbek force-pushed the improve-windows-filename-handling branch from bbb7488 to c9af675 Compare February 3, 2026 09:20
@Saidbek Saidbek force-pushed the improve-windows-filename-handling branch from d8abe69 to a8dfff3 Compare February 9, 2026 06:42
out.flush
out.chmod file_mode(entry.header.mode) & ~File.umask
end
rescue Errno::EINVAL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for providing this PR!
Is the rescue really necessary? The filenames are checked for invalid characters in advance, so why infer that EINVAL is due to an invalid character? This doesn't make sense on non-Windows OS either.

def add_files(tar) # :nodoc:
@spec.files.each do |file|
if invalid_windows_filename?(file)
alert_warning "filename '#{file}' contains characters that are invalid on Windows (e.g., colons). This gem may fail to install on Windows."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filenames are checked when packaging a gem, which is a very good thing. Could you add a test for it as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve handling of paths with colons (allowed on Unix, disallowed on Windows)

4 participants