Replace git ls-files with Dir globs in gemspec#126
Open
ogajduse wants to merge 1 commit intomdub:masterfrom
Open
Replace git ls-files with Dir globs in gemspec#126ogajduse wants to merge 1 commit intomdub:masterfrom
ogajduse wants to merge 1 commit intomdub:masterfrom
Conversation
Replace 'git ls-files' with explicit Dir globs to follow Ruby packaging best practices and avoid git dependency. Problems with git ls-files: - Includes all development files (.github/, .rubocop.yml, etc.) - Requires git to be installed (breaks in Docker, package builds) - Fails with git archive tarballs (no .git/ directory) Benefits of Dir approach: - No git dependency - works everywhere - Explicit file list - clear and maintainable - Excludes development files automatically - Recommended by Ruby Packaging Style Guide Files now included (production-ready): - lib/**/* (source code) - examples/**/* (examples) - spec/**/* (tests for development) - *.md (documentation) - LICENSE, Rakefile, Gemfile, gemspec Files automatically excluded: - .github/, .rubocop.yml, .rspec, .autotest, etc. - CODEOWNERS, Guardfile - Any other dotfiles or dev configs References: - rubygems/bundler#2287 - jfelchner/ruby-progressbar#54 - https://packaging.rubystyle.guide/ - https://docs.rubocop.org/rubocop-packaging/cops_packaging.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces
git ls-fileswith explicitDirglobs in the gemspec, following Ruby packaging best practices.Fixes #125
Changes
Modified
clamp.gemspecline 23:Why This Change?
Using
git ls-filesin gemspecs is considered bad practice by the Ruby community:Problem 1: Git dependency breaks builds
.git/directory)Problem 2: Includes unnecessary files
Current gem includes development files that bloat the package:
.github/workflows/ci.yml.rubocop.yml,.rspec,.autotest,.editorconfigCODEOWNERS,GuardfileBenefits
✅ No git dependency - Works in all build environments
✅ Explicit file list - Clear, maintainable, intentional
✅ Cleaner gems - Production-ready files only
✅ Simpler downstream packaging - No manual exclusion lists needed
✅ No breaking changes - All necessary files still included
Verification
Tested locally by building and unpacking the gem:
gem build clamp.gemspec gem unpack clamp-1.4.0.gem ls -la clamp-1.4.0/ # ✓ No .github/, no dotfilesFiles included (clean):
lib/(source code)examples/(examples)spec/(tests)CHANGES.md,README.md(documentation)LICENSE,Rakefile,Gemfile,clamp.gemspecFiles excluded (as intended):
.github/,.rubocop.yml,.rspec,.autotest, etc.CODEOWNERS,GuardfileCommunity Recommendations
This approach is recommended by:
git ls-filesis bad practice"Real-world Impact
This issue was discovered during RPM packaging for the Foreman project, where the Travis CI → GitHub Actions migration broke builds because the spec file couldn't keep up with upstream changes.
This change eliminates that maintenance burden for all downstream packagers.