NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.37k stars 14.33k forks source link

Build failure: hspec-discover-2.7.10 #340320

Open Industrial opened 2 months ago

Industrial commented 2 months ago

Steps To Reproduce

Steps to reproduce the behavior:

flake.nix:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    for-all-systems.url = "github:Industrial/for-all-systems";
    for-all-systems.inputs.nixpkgs.follows = "nixpkgs";
    flake-checks.url = "github:Industrial/flake-checks/v1.1.0";
    flake-checks.inputs.nixpkgs.follows = "nixpkgs";
    flake-devshells.url = "github:Industrial/flake-devshells";
    flake-devshells.inputs.nixpkgs.follows = "nixpkgs";
    flake-github-actions.url = "github:Industrial/flake-github-actions";
    flake-github-actions.inputs.nixpkgs.follows = "nixpkgs";
    git-hooks.url = "github:cachix/git-hooks.nix";
    git-hooks.inputs.nixpkgs.follows = "nixpkgs";
    nix-github-actions.url = "github:nix-community/nix-github-actions";
    nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
    # ghc-wasm-meta.url = "gitlab:ghc/ghc-wasm-meta?host=gitlab.haskell.org";
    ghc-wasm-meta.url = "https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz";
  };

  outputs = inputs @ {self, ...}: let
    systems = ["x86_64-linux" "aarch64-darwin"];
    forAllSystems = inputs.for-all-systems.forAllSystems {
      inherit systems;
      nixpkgs = inputs.nixpkgs;
    };
  in {
    githubActions = inputs.flake-github-actions.github-actions {
      inherit systems;
      checks = inputs.flake-checks.checks;
    } {inherit inputs;};

    checks = forAllSystems ({system, ...}:
      inputs.flake-checks.checks {
        inherit inputs system;
        run-unit-tests = false;
        custom-hooks = {
          pre-commit = {
            enable = true;
            name = "Pre Push";
            entry = "bun test && bun build";
            pass_filenames = false;
            stages = ["pre-commit"];
          };
        };
      });

    devShells = forAllSystems ({
      system,
      pkgs,
      ...
    }:
      inputs.flake-devshells.devshells {
        packages = with pkgs; [
          # Repository
          pre-commit
          direnv

          # TypeScript
          bun
          nodePackages.rollup
          jq

          # EdgeDB
          edgedb

          # Ollama
          ollama

          # Haskell
          inputs.ghc-wasm-meta.packages.${system}.all_9_10
          cabal-install
          # ghc
          haskell-language-server
          haskell.compiler.ghcjs
          haskell.packages.ghcjs.ghcjs-base
          #haskellPackages.ghc-experimental
          haskellPackages.hlint
          # wasmtime
          wasmtime
        ];
      } {inherit self system pkgs;});
  };
}

Build log

It doesn't get to a log or a .drv file because the build seems to hang on a Node.js stack trace:

[1/0/25 built] building hspec-discover-2.7.10 (buildPhase): [4 of 6] Compiling Test.Hspec.Discover.RunSpec ( test/Test/Hspec/Discover/RunSpec.hs, dist/build/spec/spec-tmp/Test/Hspec/Discover/RunSpec.js_o )direnv: ([/nix/store/ml0yghnf9h5rb4dmv1brkfi60ils8gz6-direnv-2.34.0/bin/direnv export fish]) is taking a while to execute. Use CTRL-C to give up.
[1/0/25 built] building hspec-discover-2.7.10 (checkPhase):     at FSReqCallback.oncomplete (node:fs:197:21)

Additional context

Add any other context about the problem here.

Notify maintainers

@sternenseemann you are the only maintainer I find in the file (https://github.com/NixOS/nixpkgs/blob/d1f2bc29317e05baea8db6379766a3b334f373ed/pkgs/development/haskell-modules/configuration-common.nix#L1865) which is the only notice of this package + version in nixpkgs so I hope I am tagging the right person here :-)

Metadata

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

skeleton-nodejs on  main [!⇡] via 🥟 via  
❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.47, NixOS, 24.11 (Vicuna), 24.11.20240905.9bb1e75`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"darwin, nixos-24.05"`
 - nixpkgs: `/nix/store/x615nvk9kw68cmsg01aahd1v0kzv9ifn-source`

skeleton-nodejs on  main [!⇡] via 🥟 via  took 4s 
❯ fastfetch 
          ▗▄▄▄       ▗▄▄▄▄    ▄▄▄▖             tom@huginn
          ▜███▙       ▜███▙  ▟███▛             ----------
           ▜███▙       ▜███▙▟███▛              OS: NixOS 24.11.20240905.9bb1e75 (Vicuna) x86_64
            ▜███▙       ▜██████▛               Host: StarLite (1.0)
     ▟█████████████████▙ ▜████▛     ▟▙         Kernel: Linux 6.6.47
    ▟███████████████████▙ ▜███▙    ▟██▙        Uptime: 7 days, 21 hours, 7 mins
           ▄▄▄▄▖           ▜███▙  ▟███▛        Packages: 1729 (nix-system)
          ▟███▛             ▜██▛ ▟███▛         Shell: fish 3.7.1
         ▟███▛               ▜▛ ▟███▛          Display (BOE0B36): 2160x1440 @ 60 Hz in 13″ [Built-in]
▟███████████▛                  ▟██████████▙    DE: GNOME 46.4
▜██████████▛                  ▟███████████▛    WM: Mutter (Wayland)
      ▟███▛ ▟▙               ▟███▛             WM Theme: Adwaita
     ▟███▛ ▟██▙             ▟███▛              Theme: Adwaita [GTK2/3/4]
    ▟███▛  ▜███▙           ▝▀▀▀▀               Icons: Adwaita [GTK2/3/4]
    ▜██▛    ▜███▙ ▜██████████████████▛         Font: Cantarell (11pt) [GTK2/3/4]
     ▜▛     ▟████▙ ▜████████████████▛          Cursor: Adwaita (24px)
           ▟██████▙       ▜███▙                Terminal: code 1.90.1
          ▟███▛▜███▙       ▜███▙               CPU: Intel(R) N200 (4) @ 3.70 GHz
         ▟███▛  ▜███▙       ▜███▙              GPU: Intel UHD Graphics @ 0.75 GHz [Integrated]
         ▝▀▀▀    ▀▀▀▀▘       ▀▀▀▘              Memory: 10.38 GiB / 15.47 GiB (67%)
                                               Swap: Disabled
                                               Disk (/): 142.17 GiB / 467.87 GiB (30%) - ext4
                                               Disk (/run/media/tom/Data): 2.73 GiB / 937.62 GiB (0%) - ext4
                                               Local IP (wlp0s20f3): 192.168.8.101/24
                                               Battery (AEC3756153-2S1P-N): 96% [Charging]
                                               Locale: en_US.UTF-8

Add a :+1: reaction to issues you find important.

ocfox commented 2 months ago

Try to skip that test?

sternenseemann commented 2 months ago

Please try zeroing in more on what the issue actually is. In particular:

Industrial commented 2 months ago

Minimal flake.nix:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  };
  outputs = inputs @ {self, ...}: let
    pkgs = import inputs.nixpkgs {
      system = "x86_64-linux";
    };
  in {
    devShells = {
      "x86_64-linux" = {
        default = pkgs.mkShell {
          packages = with pkgs; [
            haskell.packages.ghcjs.ghcjs-base
          ];
        };
      };
    };
  };
}

$ nix flake metadata:

Resolved URL:  git+file:///run/media/tom/Data/Code/typescript/skeleton-nodejs?dir=test
Locked URL:    git+file:///run/media/tom/Data/Code/typescript/skeleton-nodejs?dir=test
Path:          /nix/store/vpv1lybkk9wzcxih4ps2cwii1y7bdd9h-source
Revision:      3ffba97ce9a07df4b48c33d6e3718c1c473b00ed-dirty
Last modified: 2024-09-08 11:37:48
Inputs:
└───nixpkgs: github:nixos/nixpkgs/9bb1e7571aadf31ddb4af77fc64b2d59580f9a39

How do I get a build log for a derivation that hangs in the build phase?

sternenseemann commented 2 months ago

Seems like reproducing (what I believe is the same issue) is as simple as:

import GHC.Clock
main = getMonotonicTime >>= print

I don't know how to run ghcjs jsexes at the CLI, so I have the browser backtrace which seems close enough:

uncaught exception in Haskell main thread: ReferenceError: h$getMonotonicNSec is not defined [rts.js:6573:28](file:///home/lukas/Main.jsexe/rts.js)
h$baseZCGHCziClockzigetMonotonicTime1_e@file:///home/lukas/Main.jsexe/out.js:28564:3
h$runThreadSlice@file:///home/lukas/Main.jsexe/rts.js:7499:11
h$runThreadSliceCatch@file:///home/lukas/Main.jsexe/rts.js:7467:12
h$mainLoop@file:///home/lukas/Main.jsexe/rts.js:7462:9
partiallyApplied/<@file:///home/lukas/Main.jsexe/rts.js:2504:25
runIfPresent@file:///home/lukas/Main.jsexe/rts.js:2518:21
onGlobalMessage@file:///home/lukas/Main.jsexe/rts.js:2554:29

Smells like a ghcjs problem, though we don't exactly ship the upstream ghcjs 8.10, but a fork of Obsidian Systems. cc @dfordivam @obsidian-systems-maintenance

dfordivam commented 2 months ago

Yes, the getMonotonicTime is a ghcjs problem. It doesn't exist on 8.10 on either our fork or upstream.

On ghc HEAD (or 9.10) this should work https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/ghc-internal/src/GHC/Internal/Clock.hsc?ref_type=heads#L40

#if defined(javascript_HOST_ARCH)
getMonotonicTimeNSec :: IO Word64
getMonotonicTimeNSec = do
  w <- getMonotonicTimeMSec
  return (floor w * 1000000)

foreign import javascript unsafe "performance.now" getMonotonicTimeMSec:: IO Double
dfordivam commented 2 months ago

I vaguely remember seeing this issue in the past. The best solution here is to avoid running hspec with ghcjs. Which means avoid running check phase /testsuite of hspec-discover-2.7.10 (checkPhase). This could be done by dontCheck override in flake.nix, or better do it here?

https://github.com/NixOS/nixpkgs/blob/6a4de5f83d386e33ea3d219b58660b3e9381f728/pkgs/development/haskell-modules/configuration-ghcjs-8.x.nix#L120

dfordivam commented 2 months ago

Related https://github.com/NixOS/nixpkgs/blob/6a4de5f83d386e33ea3d219b58660b3e9381f728/pkgs/development/haskell-modules/configuration-ghcjs-8.x.nix#L125-L127

  # Without this revert, test suites using tasty fail with:
  # ReferenceError: h$getMonotonicNSec is not defined
  # https://github.com/UnkindPartition/tasty/pull/345#issuecomment-1538216407