Skip to content

“Stack 3.7.1: linker (-lgmp) failure & wrong toolchain when building vpf-class project” #6814

@tabby678

Description

@tabby678

Please follow the steps below for reporting a bug in Stack:

Make sure that you are using the latest release (currently Stack 3.7.1). See the
upgrade instructions
to upgrade.

Please use the following schema for your bug report:

General summary/comments (optional)

Trying to build and run the vpf-tools project (exec target vpf-class) on a shared HPC host. I upgraded to Stack 3.7.1 in my home (~/.local/bin/stack), but I’m seeing a few rough edges:
GHC setup/build fails when a conda toolchain is present: the link step uses x86_64-conda-linux-gnu-cc and errors with cannot find -lgmp. Even after providing GMP via conda, Stack/GHC still prefer the conda toolchain unless I scrub env vars.
GHC sanity check and setup produce confusing failures if libtinfo.so.5/GMP are missing.
If STACK_ROOT isn’t exported in the shell, Stack quietly falls back to ~/.stack and tries to unpack GHC there (low-space home), leading to tar Jxf … failures.
In Stack 3.x, --work-dir no longer accepts absolute paths; the error is correct but took a while to discover (docs/UI hint could be clearer).
When a non-ASCII space sneaks into exec --, Stack treats it like runghc and the “Invalid argument vpf-class” message is non-obvious; a more explicit hint would help.
Not all of these are “bugs” per se, but #1 (toolchain contamination) and #5 (diagnostic clarity) might be actionable.

Steps to reproduce

Ensure a conda environment is active (e.g., base), so x86_64-conda-linux-gnu-cc is on PATH/CC.
Clone project and cd:
git clone https://github.com/biocom-uib/vpf-tools
cd vpf-tools

Use user-local Stack:
export PATH=$HOME/.local/bin:$PATH # stack 3.7.1
export STACK_ROOT=/mnt/nas/vol2/fiza/stackroot
Build:
stack --allow-different-user --stack-root "$STACK_ROOT" --work-dir .stack-work-fiza build
Observe link failure using conda toolchain:
/usr/local/miniconda3/.../ld: cannot find -lgmp
x86_64-conda-linux-gnu-cc' failed in phase Linker'. (Exit code: 1)
(If STACK_ROOT is not set) Stack falls back to ~/.stack and GHC unpack fails in a low-space home:
Error: [S-7441]
Raw command: /usr/bin/tar Jxf /home//.stack/programs/x86_64-linux/ghc-8.10.2.tar.xz
Using an absolute --work-dir:
stack --work-dir /mnt/nas/vol2/fiza/vpf-stack-work build
yields:
option --work-dir: ... Stack will not accept an absolute path.
If a non-ASCII space is copied before --, e.g. exec -- vpf-class:
stack: WARNING! Using runghc ...
Invalid argument `exec --'
Error executing interpreter command: stack exec -- vpf-class ...

Include any .yaml configuration, if relevant.
Project stack.yaml is the one in biocom-uib/vpf-tools (resolver targets GHC 8.10.x).

Expected

What you expected to see and happen.
Stack/GHC should ignore conda’s compiler/toolchain by default (or provide a clear hint) and use a system toolchain, or error with a message pointing to GMP/ncurses requirements and how to avoid conda toolchain contamination.

Clearer diagnostics when --work-dir is absolute (e.g., print “use a relative path like .stack-work-user”).

If a non-ASCII space appears in exec --, emit a specific message (“non-ASCII whitespace detected near --; please retype with ASCII space”).

Actual

What actually happened.
Link step fails with:

/usr/local/miniconda3/.../ld: cannot find -lgmp
x86_64-conda-linux-gnu-cc' failed in phase Linker'. (Exit code: 1)
GHC sanity check complains about:
/lib64/libtinfo.so.5: no version information available ...
and then fails to link if GMP/ncurses-compat are missing.
If STACK_ROOT is not exported, Stack tries to unpack GHC into ~/.stack and fails (tar Jxf ... ExitFailure 2) due to space/corruption.
Absolute --work-dir is rejected (as designed) but the error took time to interpret.
Non-ASCII space in exec -- produces runghc invocation and “Invalid argument exec --”, which is confusing.

If you suspect that a Stack command misbehaved, please include the output of
that command in --verbose mode. If the output is larger than a page please
paste the output in a Gist.

conda active; toolchain visible; missing system gmp/libtinfo

stack --allow-different-user --stack-root "$STACK_ROOT" --work-dir .stack-work-fiza build --verbose

stack <your command here> <args> --verbose
<output>

Stack version

stack --version
Version 3.7.1, Git revision cfae313 x86_64 hpack-0.38.1

stack --version
Version 3.7.1, Git revision cfae313a06ea9f7278e0ac55a58341fa0440f1aa x86_64 hpack-0.38.1

Method of installation

Official binary via stack upgrade (placed at ~/.local/bin/stack).
A legacy system-wide 2.7.3 exists in /usr/local/bin (cannot be overwritten; no sudo).

  • Official binary, downloaded via haskellstack.org or from Stack's repository
  • Via GHCup
  • Via Cabal (the tool)
  • An unofficial package repository (please specify which)
  • Other (please specify)

Platform

x86_64 Linux on an HPC node (RHEL/CentOS/Rocky family; no sudo).
Conda is commonly used on the cluster; envs expose x86_64-conda-linux-gnu-cc.
Your platform (machine architecture and operating system)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions