Skip to content

Extend flag(os-string) handling to test-suites#52

Open
ulidtko wants to merge 1 commit into
haskell:masterfrom
ulidtko:tests/os-string-flag
Open

Extend flag(os-string) handling to test-suites#52
ulidtko wants to merge 1 commit into
haskell:masterfrom
ulidtko:tests/os-string-flag

Conversation

@ulidtko

@ulidtko ulidtko commented Feb 18, 2026

Copy link
Copy Markdown

GHC's pkgdb permits having multiple versions of a library installed side-by-side.

So, one can end up with:

$ ghc-pkg list -v 2>&1 | grep filepath
    filepath-1.4.300.1 (filepath-1.4.300.1)
    filepath-1.5.5.0 (filepath-1.5.5.0-4NuYd63ABenDOAyOjf3bpG)

— and I certainly did.

In an environment like this, file-io v0.2.0 succeeds build with --disable-tests, and fails build with --enable-tests. The build system gets confused which package links where, cabal starts making bizarre decisions in its Linked component graph, and the different PosixPath types stop aligning.

This patch prevents that issue, by ensuring that tests always speak the same PosixPath as the main lib, in any build configuration.

common stanzas and import are since cabal-version: 2.2 — thus no bump was required. Unfortunately, import is only allowed on the first line of a block.


TL;DR: this fixes build with --enable-tests in uncommon conditions during distro packaging.

@hasufell

Copy link
Copy Markdown
Member

The build system gets confused which package links where, cabal starts making bizarre decisions

Do you have a reproducer? This sounds like something that needs investigation.

Comment thread file-io.cabal
main-is: T15.hs
type: exitcode-stdio-1.0
default-language: Haskell2010
build-depends: base >=4.13.0.0 && <5, tasty, tasty-hunit, file-io, filepath, temporary

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need filepath here anymore (same for the other tests)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried dropping the dependency: all tests are importing System.OsPath — and then emit member of the hidden package errors.

@ulidtko

ulidtko commented Feb 19, 2026

Copy link
Copy Markdown
Author

Do you have a reproducer?

Yes; minimized, here.

Dockerfile
FROM haskell:9.6.6-slim

RUN cabal update && \
    cabal v1-install --global filepath --constraint 'filepath >=1.5' && \
    echo "Confirm the environment, two versions expected:" && \
    ghc-pkg list -v | grep filepath

RUN echo "Test-deps" && \
    cabal v1-install --global tasty-hunit temporary

RUN cd /tmp && \
    git clone https://github.com/haskell/file-io && \
    echo 'module Main(main) where { import Distribution.Simple; main = defaultMain; }' > file-io/Setup.hs

WORKDIR /tmp/file-io

#-- NOTE: uncommenting the PR patch fixes build with tests
#RUN curl -fSsL https://github.com/haskell/file-io/pull/52.diff | patch -p1

RUN echo '=== WITHOUT TESTS ==='; \
    set -x; \
    runhaskell Setup configure --disable-tests --verbose && \
    runhaskell Setup build

RUN echo '=== WITH TESTS ==='; \
    set -x; \
    runhaskell Setup configure --enable-tests --verbose && \
    runhaskell Setup build

@hasufell if you try docker build - < this.dockerfile ☝️ as is — (only) the last step fails. If you uncomment the curl | patch line — both succeed.

I know, I know, this is chokefull of unsavory "legacy" and "not recommended" approaches — but this faithfully replicates how entire distro lineages are installing haskell things.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants