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

Cabal doesn't see happy on PATH #9904

Open
yaitskov opened this issue Apr 17, 2024 · 3 comments
Open

Cabal doesn't see happy on PATH #9904

yaitskov opened this issue Apr 17, 2024 · 3 comments

Comments

@yaitskov
Copy link

Describe the bug
cabal fails to build happy complaining that happy executable is not found, nonetheless happy is on PATH

To Reproduce

$ git clone https://github.com/yaitskov/happy-ghc11/tree/master
# commit just in case 71d4ad5a862793dd1753a1a6b453346e9533157d
$ nix-shell
....
Preprocessing executable 'happy' for happy-1.21.0..
Error: Setup: The program 'happy' is required but it could not be found

error: builder for '/nix/store/ccphy1szsn9fg2lx80p299bib2ky9izp-happy-1.21.0.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/l73rh8grlx1wqsjshdf344x44c75g2cj-ghc-9.8.1-with-packages.drv' failed to build

System information

cabal --version
cabal-install version 3.10.3.0
compiled using version 3.10.3.0 of the Cabal library 

uname -a
Linux diehard 5.13.11 #1 SMP Sun Aug 15 11:46:11 EDT 2021 x86_64 GNU/Linux

Workaround

cabal --extra-prog-path=$(which happy) build 

I guess it is expected behavior, but the fact that cabal is using alternative PATH not related to canonical BASH one is not obvious at all. I would not close the issue until error message is extended mentioning this - e.g. suggesting extra-prog-path or just borrow whole PATH.

@gbaz
Copy link
Collaborator

gbaz commented Apr 17, 2024

Cabal does make use of the path environment variable. "extra-prog-path" as it says is just an extra path to augment the existing system path. It is not clear to me how your system is configured that this does not work.

Perhaps when you enter the nix-shell the path is overridden?

@ffaf1
Copy link
Collaborator

ffaf1 commented Apr 17, 2024

If $(which happy) works, then executable is in PATH. I would consider this a bug, not a user question.

@yaitskov, we need your help to diagnose this, cabal build -v3 or similar prints enviroment variables (starting with with environment). Can you tel us how ("PATH","… differs from echo $PATH?

@yaitskov
Copy link
Author

yaitskov commented Apr 17, 2024

Cabal does make use of the path environment variable

I started grepping cabal source code - exception is thrown from lookupProgram which looks into a some Db and I assumed that program is referred in such a way is expected to be "cabally installed". I didn't trace all way.

Here is another way to reproduce the issue, which is easier to investigate

$ rm -rf ~/.cabal ~/.local/state/cabal ~/.cache/cabal
$ git clone https://github.com/haskell/happy.git 
# commit 78dcc03336d74822d58b8474e9639c6281c1a422
$ cd happy
cat<<EOF > ./default.nix
{ pkgs ? import <nixpkgs> {} }:
let
  inherit (pkgs) lib;
  hp = pkgs.haskell.packages.ghcHEAD;
  sourceRegexes = [
    "^src.*"
    "^exe.*"
    "^package.yaml"
    "^.*\\.cabal"
    "^LICENSE"
  ];

  shell = hp.shellFor {
    packages = p: [];
    shellHook = ''echo ok'';
    nativeBuildInputs = [ pkgs.cabal-install pkgs.happy ];
  };
in
{ inherit shell; }

EOF
$ nix-shell
$ type happy
happy is /nix/store/4z00pcvs075ghpnyhsvg6xg54kzncv5m-happy-1.20.1.1/bin/happy
$ cd packages/frontend # important step
$ cabal build
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.10.3.0 supports
'ghc' version < 9.10):
/nix/store/z3d4vkisfchw9ydyalax4q32pp5ry0dr-ghc-9.11.20240323/bin/ghc is
version 9.11.20240323
Build profile: -w ghc-9.11.20240323 -O1
In order, the following will be built (use -v for more details):
 - happy-frontend-2.0 (lib) (first run)
 - happy-3.0 (exe:happy) (first run)
Preprocessing library for happy-frontend-2.0..
Error: .cabal-wrapped: The program 'happy' is required but it could not be
found

Error: cabal: Failed to build happy-frontend-2.0 (which is required by
exe:happy from happy-3.0).


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants