Skip to content

Define SafeShell::VERSION when the gem is required - #35

Merged
orien merged 1 commit into
mainfrom
require-version
Nov 29, 2026
Merged

orien merged 1 commit into
mainfrom
require-version

Conversation

@orien

@orien orien commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Context

SafeShell::VERSION lives in lib/safe_shell/version.rb, which ships in the gem but only the gemspec requires. After require "safe_shell" the constant is undefined, so a caller can't read the version without requiring the file by its path.

PE-8869

Change

Requires the version file from lib/safe_shell.rb, and adds an example that checks the constant is defined after require "safe_shell".

Considerations

  • The example runs a separate Ruby with RubyGems disabled. Under bundle exec, Bundler loads the gemspec, which defines the constant whether or not the library does, so an in-process check would pass without the fix.

The version constant lives in lib/safe_shell/version.rb, which only the
gemspec required, so after require "safe_shell" it was undefined. Require
it from the library.

The spec runs a separate Ruby with RubyGems disabled: under Bundler the
gemspec is loaded, which defines the constant whether or not the library
does.
@orien
orien marked this pull request as ready for review November 29, 2026 14:33
@orien
orien merged commit 49cb9b0 into main Nov 29, 2026
16 checks passed
@orien
orien deleted the require-version branch November 29, 2026 14:33
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