fpco / weigh

Measure allocations of a Haskell functions/values

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setting file does not exists and empty results

guibou opened this issue · comments

I'm not able to obtain any result using weigh 0.0.16 provided by nix.

I'm using the following nix file to setup ghc 8.6.5 and weigh 0.0.16:

weigh-bug-report.nix

with import (builtins.fetchTarball {
url = https://github.com/NixOS/nixpkgs/archive/3140fa89c51.tar.gz;
sha256 = "18p0d5lnfvzsyfah02mf6bi249990pfwnylwhqdh8qi70ncrk3f8";
}) {};
mkShell {
  buildInputs = [ (pkgs.haskellPackages.ghcWithPackages(p : [
    (
      p.callHackageDirect {
        pkg = "weigh";
        ver = "0.0.16";
        sha256 = "0icdyvxxi7493ch8xlpwn024plspbsdssxmcy5984yar298z8hcw";
      } {}
    )
  ]))];
}

Then, the following invocations:

$ nix-shell ./weigh-bug-report.nix

[nix-shell:~]$ ghc-pkg list | grep weigh
    weigh-0.0.16

[nix-shell:~]$ ghci
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude> import Weigh

-- `mainWith` is failing with a surprising error

Prelude Weigh> mainWith $ do func "bar" sum [(1 :: Int)..10]
*** Exception: Error in case ("/bar"):
  /nix/store/jxrl0fcihi2vpxyf0makql4208ggx3fs-ghc-8.6.5/lib/ghc-8.6.5/lib/settings: openFile: does not exist (No such file or directory)

CallStack (from HasCallStack):
  error, called at src/Weigh.hs:384:12 in weigh-0.0.16-GXMBccy3Rx4880KgeLr7zE:Weigh

-- Note that other invocation are not failing, but returns nothing:

Prelude Weigh> mainWith $ do func "bar" sum [(1 :: Int)..10]
Prelude Weigh> weighResults $ func "bar" sum [1..10]
([],Config {configColumns = [Case,Allocated,GCs], configPrefix = "", configFormat = Plain})

As you can see, it fails with a file does not exist error. It may be due to the non standard file layout of nix.

@guibou I think the problem is in extra lib in that path, e.g. locally I have those settings in /nix/store/8fil9jim41clgkfbchn8yq14azgbr1zd-ghc-8.6.5/lib/ghc-8.6.5/settings
I'm not quite sure where those get loaded but my hypothesis is that maybe Nix somehow gets in a way of directory resolution.

Wait, does weigh works in ghci for you? I just realized that it works fine here in a compiled program, but not in GHCi.

@guibou that was just a note about paths, I didn't try starting GHCi in a nix-shell. The idea was that it could be a hint to resolve the problem

Weigh runs the current process again with different environment variables. If it works in GHCi, it would be a surprise.

@chrisdone I do understand. Should we close this bug as "won't fix by design"?

Sure.