Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shebang for binaries in JRuby #98693

Merged
merged 1 commit into from Sep 25, 2020
Merged

Conversation

fzakaria
Copy link
Contributor

@fzakaria fzakaria commented Sep 24, 2020

Motivation for this change

There are a variety of additional scripts that are included with the
JRuby installation that use JRuby itself.

For instance the bin/gem had the following contents:

❯ cat /nix/store/kglkqf56ii83yl6yrgcaj5r3s9m2fzr0-jruby-9.2.13.0/bin/gem

#!/nix/store/k4fnrn0dcsh2wzw81217r0ywsspb468f-jruby-9.2.13.0/bin/jruby

# Just load jgem, since that's what RubyGems updates.
load File.join(File.dirname(__FILE__), 'jgem')

This is clearly wrong. Patchshebangs was not picking up the fix as part
of stdenv because the patch is not a build input but the final output
itself.

Things done

We have to rely on patchShebangs but with a modified $PATH.

❯ cat /nix/store/k4fnrn0dcsh2wzw81217r0ywsspb468f-jruby-9.2.13.0/bin/gem
#!/nix/store/k4fnrn0dcsh2wzw81217r0ywsspb468f-jruby-9.2.13.0/bin/jruby

# Just load jgem, since that's what RubyGems updates.
load File.join(File.dirname(__FILE__), 'jgem')
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

CC @volth @mimame @asppsa @zimbatm (tagged a few people who've modified the file)

@fzakaria
Copy link
Contributor Author

Result of nixpkgs-review pr 98693 1

1 package built:
- jruby

There are a variety of additional scripts that are included with the
JRuby installation that use JRuby itself.

For instance the `bin/gem` had the following contents:

```bash
❯ cat /nix/store/kglkqf56ii83yl6yrgcaj5r3s9m2fzr0-jruby-9.2.13.0/bin/gem

load File.join(File.dirname(__FILE__), 'jgem')
```

This is clearly wrong. Patchshebangs was not picking up the fix as part
of stdenv because the patch is not a build input but the final output
itself.

We have to rely on substituteInPlace so that we get the correct version.

```bash
❯ cat /nix/store/k4fnrn0dcsh2wzw81217r0ywsspb468f-jruby-9.2.13.0/bin/gem

```
Comment on lines +43 to +45
postFixup = ''
PATH=$out/bin:$PATH patchShebangs $out/bin
'';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mic92
Copy link
Member

Mic92 commented Sep 25, 2020

Result of nixpkgs-review pr 98693 1

1 package built:
  • jruby

@Mic92 Mic92 merged commit 7011d44 into NixOS:master Sep 25, 2020
@Mic92
Copy link
Member

Mic92 commented Sep 25, 2020

backport: e703709

fzakaria pushed a commit to fzakaria/nixpkgs that referenced this pull request Sep 27, 2020
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.

None yet

2 participants