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 shell in ammonite package #68151 #73905

Merged
merged 1 commit into from Dec 1, 2019
Merged

Conversation

@lourkeur
Copy link
Contributor

lourkeur commented Nov 22, 2019

Motivation for this change

The amm command doesn't work when started from the fish shell because it lacks a shebang.

Things done
  • 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 (Arch Linux with Arch Linux provided fish)
  • 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 nix-review --run "nix-review wip" No diff detected
  • 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) +8 bytes
  • Ensured that relevant documentation is up to date Nothing to update AFAICT
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @NeQuissimus

Upstream doesn't include a shebang line but recommends adding one at
installation time. NixOS users noticed that the command wouldn't exec
when using certain shells.
@doom3wasagoodgame

This comment has been minimized.

Copy link
Contributor

doom3wasagoodgame commented Nov 22, 2019

Have you considered using #!/usr/bin/env bash because #!/bin/sh is not always bash. Otherwise 👍 LGTM

@lourkeur

This comment has been minimized.

Copy link
Contributor Author

lourkeur commented Nov 22, 2019

Have you considered using #!/usr/bin/env bash because #!/bin/sh is not always bash. Otherwise LGTM

Good question. Upstream recommends /usr/bin/env sh (oddly enough) as a shebang. The shell script[1] looks like it's meant to not only work with any POSIX sh but also with batch.exe. It's very short because the rest of the file is in fact the JAR and I don't see any bashisms. To test this hypothesis further, I passed it to dash and surely enough, ammonite started as usual. Thus I think /bin/sh is appropriate.

[1]

@ 2>/dev/null # 2>nul & echo off & goto BOF
:
exec /nix/store/qdb4a4qww23a6cb408qi5r7ypmk1c6dp-openjdk-8u222-ga-jre/bin/java -Xmx500m -XX:+UseG1GC $JAVA_OPTS -cp "$0" ammonite.Main --no-remote-logging "$@"
exit

:BOF
@echo off
java -Xmx500m -XX:+UseG1GC %JAVA_OPTS% -cp "%~dpnx0" ammonite.Main %*
exit /B %errorlevel%
PK
... rest of the jar
@flokli flokli changed the title fix #68151 fix shell in ammonite package #68151 Nov 25, 2019
@lourkeur

This comment has been minimized.

Copy link
Contributor Author

lourkeur commented Nov 25, 2019

I ticked "Tested using sandboxing" because I realised it was on the whole time.

nix-review says No diff detected, stopping review...

Package closure size:

Before
/nix/store/xmap6fl3rglvczvgz946fp83l4mh2wna-ammonite-1.7.4	  431872784
After
/nix/store/2irpkws16m4bbsykzmg8dknapjix59qn-ammonite-1.7.4	  431872792
@nixos-discourse

This comment has been minimized.

Copy link

nixos-discourse commented Nov 30, 2019

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-in-distress/3604/14

@lilyball

This comment has been minimized.

Copy link
Member

lilyball commented Dec 1, 2019

I've tested this on macOS. Seems to work.

> nix-shell -E 'with import ./default.nix {}; mkShell { buildInputs = [ ammonite fish ]; }'
these derivations will be built:
  /nix/store/3gzk5ycx0akp04jr1hfhw5ppmns15ww8-ammonite-1.7.4.drv
these paths will be fetched (293.54 MiB download, 1103.47 MiB unpacked):
  […]

[nix-shell:~/Dev/Nix/nixpkgs]$ fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
fish prompt> amm
Loading...
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/replBridge.sc
Compiling (synthetic)/ammonite/predef/sourceBridge.sc
Compiling (synthetic)/ammonite/predef/frontEndBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Welcome to the Ammonite Repl 1.7.4
(Scala 2.13.1 Java 1.8.0_222)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@
@NeQuissimus NeQuissimus merged commit 37c644e into NixOS:master Dec 1, 2019
15 checks passed
15 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
ammonite on aarch64-linux Success
Details
ammonite on x86_64-linux Success
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A darwin-tested
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release-combined.nix -A tested
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@lourkeur lourkeur deleted the lourkeur:master+fix_68151 branch Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.