NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.41k stars 14.36k forks source link

perlPackages.TAPParserSourceHandlerpgTAP (pg_prove) broken #55663

Open srghma opened 5 years ago

srghma commented 5 years ago

Issue description

+ pg_prove -h postgres -p 5432 -d gb_test -U app_admin --recurse --ext .sql /db_tests/tests/
Could not execute (psql --no-psqlrc --no-align --quiet --pset pager=off --pset tuples_only=true --set ON_ERROR_STOP=1 --username app_admin --host postgres --port 5432 --dbname gb_test --file /db_tests/tests/actions/confirm/error_when_token_invalid.sql): open3: exec of psql --no-psqlrc --no-align --quiet --pset pager=off --pset tuples_only=true --set ON_ERROR_STOP=1 --username app_admin --host postgres --port 5432 --dbname gb_test --file /db_tests/tests/actions/confirm/error_when_token_invalid.sql failed: No such file or directory at /nix/store/hp6bsml2b0vzxd2y8vwz060m8w373bd7-perl-5.28.1/lib/perl5/5.28.1/TAP/Parser/Iterator/Process.pm line 165.

Steps to reproduce

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the results.

srghma commented 5 years ago

ok, I found, it threw because postgres wasnt in $PATH

e.g. it fails with this $PATH

              PATH =
                let
                  env = pkgs.buildEnv {
                    name = "system-path";
                    paths = with pkgs; [
                      perlPackages.TAPParserSourceHandlerpgTAP # pg_prove
                    ];
                  };
                in "${env}/bin:/bin:/run/system/bin";

but it doesn't fail with this $PATH

              PATH =
                let
                  env = pkgs.buildEnv {
                    name = "system-path";
                    paths = with pkgs; [
                      postgresql
                      perlPackages.TAPParserSourceHandlerpgTAP # pg_prove
                    ];
                  };
                in "${env}/bin:/bin:/run/system/bin";

I'm fine with this behavior because it allows to execute pg_prove with different postgres versions in path

srghma commented 5 years ago

actually I'm not sure about my desition. Is it better to:

  1. leave it as it is, user should add postgres as dependency by hand
{ stdenv, postgresql, perlPackages, makeWrapper, lib }:

# pgql is required to be in $PATH (https://github.com/NixOS/nixpkgs/issues/55663)
stdenv.mkDerivation rec {
  name = "pg_prove";

  nativeBuildInputs = [ makeWrapper ];

  phases = [ "installPhase" ];

  installPhase = ''
    mkdir -p $out/bin

    makeWrapper ${perlPackages.TAPParserSourceHandlerpgTAP}/bin/pg_prove $out/bin/pg_prove \
      --prefix PATH : ${lib.makeBinPath [ postgresql ]}

    makeWrapper ${perlPackages.TAPParserSourceHandlerpgTAP}/bin/pg_tapgen $out/bin/pg_tapgen \
      --prefix PATH : ${lib.makeBinPath [ postgresql ]}
  '';
}

OR

  1. wrapProgram around perlPackages.TAPParserSourceHandlerpgTAP itself and allow user to override it as
perlPackages.TAPParserSourceHandlerpgTAP.override {
  postgres = postgres10;
};
stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.