fix: preserve Nix Ruby in init wrapper#116
Open
pcasaretto wants to merge 1 commit into
Open
Conversation
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.
Problem
The Nix/Home Manager install path generated a broken shell function from
try init.tryneeds to install a shell function because a subprocess cannotcdthe parent shell. That function capturestry execoutput and evals it.Before this change, the generated function invoked the Ruby script explicitly through the ambient Ruby:
out=$(/usr/bin/env ruby '/nix/store/.../bin/.try-wrapped' exec ...)For Nix builds,
wrapPrograminstalls:When
try initruns under that wrapper,$0resolves to the internal.try-wrappedscript. The emitted shell function therefore bypassesbin/try, which means it also bypasses the Nix-provided Ruby. On macOS this falls back to the system Ruby, which is too old for the current code and fails at runtime.In short:
Fix
This removes the wrapper layer from the Nix package and makes the generated shell function call the resolved executable directly.
Changes:
try initnow emits direct executable calls:out=$('/path/to/try' exec ...)instead of:
out=$(/usr/bin/env ruby '/path/to/try' exec ...)The Nix derivation no longer uses
wrapProgram.The Nix derivation patches the installed script shebang to the packaged Ruby:
#!/nix/store/...-ruby-3.3.x/bin/rubyAs a result, the Nix package contains a single public executable script:
There is no
.try-wrapped, no package-specific logic in the Ruby code, and the shell integration preserves the executable selected by the installer/package manager.Tests
nix build . ./spec/tests/runner.sh ./result/bin/tryResult: