Skip to content

Resolve globbed entries literally in Gem::Util.glob_files_in_dir - #9802

Merged
hsbt merged 3 commits into
masterfrom
claude/practical-wu-64037b
Aug 24, 2026
Merged

Resolve globbed entries literally in Gem::Util.glob_files_in_dir#9802
hsbt merged 3 commits into
masterfrom
claude/practical-wu-64037b

Conversation

@hsbt

@hsbt hsbt commented Aug 24, 2026

Copy link
Copy Markdown
Member

Follow-up to #9687. Gem::Util.glob_files_in_dir resolved matched entries with File.expand_path, so an entry starting with ~ was expanded into the home directory. A cache directory named ~ made bundle cache pruning delete files under $HOME, and an entry like ~user raised ArgumentError. Matched entries are now joined literally to the base path.

This also migrates the remaining call sites that still interpolated install paths into glob patterns (gem contents, gem stale, the gem setup old-doc cleanup, and bundle doctor), which returned no matches when the install path contains glob metacharacters, and routes setup_manpath through the shared helper for consistency.

Generated with Claude Code

hsbt and others added 3 commits August 24, 2026 17:07
Matched entries were resolved with File.expand_path, so an entry starting with `~` was expanded into the home directory. A cache directory named `~` made `bundle cache` pruning delete files under `$HOME`, and an entry like `~foo` raised `ArgumentError`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`gem contents`, `gem stale` and the `gem setup` old-doc cleanup returned no matches when the install path contains glob metacharacters. For `--lib-only`, glob `raw_require_paths`, which stay relative to `full_gem_path`, rather than `require_paths`, which prepends the absolute `extension_dir` and would escape the glob base.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bundler runs against whatever RubyGems the host provides, so calling `Gem::Util.glob_files_in_dir` left `bundle cache` pruning able to resolve a cache entry named `~` to the real home directory and hand it to `FileUtils.rm_rf` on every RubyGems older than that fix. Move the helper into `SharedHelpers`. This also covers `bundle doctor`, which previously found no `.bundle` files under an install path containing glob metacharacters.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hsbt
hsbt force-pushed the claude/practical-wu-64037b branch from 636c234 to 4d79dce Compare August 24, 2026 08:08
@hsbt
hsbt merged commit cba5545 into master Aug 24, 2026
110 checks passed
@hsbt
hsbt deleted the claude/practical-wu-64037b branch August 24, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant