Skip to content

Use UTF-8 encoding for GHCi -unit response file arguments - #12574

Merged
mergify[bot] merged 3 commits into
haskell:masterfrom
fendor:wip/fendor/fix-unit-file-encoding
Nov 15, 2026
Merged

mergify[bot] merged 3 commits into
haskell:masterfrom
fendor:wip/fendor/fix-unit-file-encoding

Conversation

@fendor

@fendor fendor commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Fixes #12573

Updates the cabal-testsuite to use UTF-8 encoding appropriately, otherwise the tests crash due to the same encoding error that plagues -unit @rsp.


Template B: This PR does not modify behaviour or interface

E.g. the PR only touches documentation or tests, does refactorings, etc.

Include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

@fendor

fendor commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

I think, in theory, it is worth reviewing every occurrence of Data.ByteString.Char8 and review it for its correctness.
While skimming the codebase, I found multiple locations where the usage is dubious (i.e. I wasn't immediately convinced the usage was correct).

@fendor
fendor force-pushed the wip/fendor/fix-unit-file-encoding branch 3 times, most recently from f4e9d49 to bf904ca Compare November 11, 2026 14:00
@fendor
fendor force-pushed the wip/fendor/fix-unit-file-encoding branch 2 times, most recently from 98f951d to 9cdd305 Compare November 11, 2026 14:35
@fendor fendor changed the title Use UTF-8 encoding to for GHCi -unit response file arguments Use UTF-8 encoding for GHCi -unit response file arguments Nov 11, 2026
@fendor
fendor force-pushed the wip/fendor/fix-unit-file-encoding branch from 9cdd305 to dabcb3d Compare November 11, 2026 15:53
@Mikolaj

Mikolaj commented Nov 11, 2026

Copy link
Copy Markdown
Member

I think, in theory, it is worth reviewing every occurrence of Data.ByteString.Char8 and review it for its correctness. While skimming the codebase, I found multiple locations where the usage is dubious (i.e. I wasn't immediately convinced the usage was correct).

Would it fit this PR or would a new PR be better? If the latter, could you kindly open a ticket so that we don't forget?

@Mikolaj Mikolaj left a comment

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.

Thank you!

@mergify mergify Bot added the 1️⃣ more approval needed Set by Mergify: has one of the two required approvals label Nov 11, 2026
@mergify mergify Bot removed the 1️⃣ more approval needed Set by Mergify: has one of the two required approvals label Nov 11, 2026
@fendor

fendor commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Would it fit this PR or would a new PR be better? If the latter, could you kindly open a ticket so that we don't forget?

I think another PR is better, this fixes a real bug, the other occurrences could be benign. Also, I am not committing to review the whole cabal codebase 😬

@fendor

fendor commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you all for the thorough review, not my proudest PR, given the amount of oversights :D

@fendor
fendor force-pushed the wip/fendor/fix-unit-file-encoding branch 2 times, most recently from 3404405 to 296efc5 Compare November 12, 2026 08:55
@fendor

fendor commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

I created an issue: #12580

@fendor
fendor force-pushed the wip/fendor/fix-unit-file-encoding branch from 296efc5 to 6a5dba8 Compare November 12, 2026 09:17
@fendor fendor added the merge me Tell Mergify Bot to merge label Nov 12, 2026
@mergify mergify Bot added the ready and waiting Mergify is waiting out the cooldown period label Nov 12, 2026
@mergify mergify Bot added merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days queued labels Nov 14, 2026
@mergify

mergify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Validate macos-15 ghc-9.12.4 failed

1 h 47 min in the queue, 1 h 35 min of it CI.

So far

Not proven to be this pull request's failure. It failed on top of the pull requests ahead of it, and was not tested alone.

Reason

The merge conditions cannot be satisfied due to failing checks

  • Validate post job

Failing checks:

To get back in the queue

  • If the failure comes from the pull requests it was tested with, or is a flake, comment @mergifyio queue to queue it again as it is.
  • If it is this pull request's, push a fix: the pull request is queued again once its queue conditions match.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = Validate post job
    • check-skipped = Validate post job
    • check-success = Validate post job
11 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of · required by GitHub branch protection:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of · required by GitHub branch protection:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of · required by GitHub branch protection:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of · required by GitHub branch protection:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of · required by GitHub branch protection:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of · required by GitHub branch protection:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of · required by GitHub branch protection:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of · required by GitHub branch protection:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

Times in UTC · dashboard · how the merge queue works

@zlonast

zlonast commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

@Mergifyio queue

@mergify

mergify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as adb907e at 06:11 UTC

1 h 53 min in the queue, 1 h 42 min of it CI.

So far

12 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of · required by GitHub branch protection:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of · required by GitHub branch protection:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of · required by GitHub branch protection:
    • check-success = Validate post job
    • check-neutral = Validate post job
    • check-skipped = Validate post job
  • any of · required by GitHub branch protection:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of · required by GitHub branch protection:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of · required by GitHub branch protection:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of · required by GitHub branch protection:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of · required by GitHub branch protection:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of · required by GitHub branch protection:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added queued and removed dequeued labels Nov 15, 2026
@mergify
mergify Bot merged commit adb907e into haskell:master Nov 15, 2026
85 checks passed
@mergify mergify Bot removed the queued label Nov 15, 2026
@zlonast

zlonast commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

I suspect that this doesn't work:
CI failed: https://github.com/haskell/cabal/actions/runs/43799842757/job/133079533708?pr=12051

cabal-testsuite/PackageTests/BuildTypeConfigure/Component/cabal.test.hs                                                           OK (5.98s)
cabal-testsuite/PackageTests/MultiRepl/KeepTempFiles/cabal.test.hs                                                                OK (2.58s)
cabal-testsuite/PackageTests/WorkingDir/setup.test.hs                                                                             OK (9.91s)
cabal-tests: fd:16: commitBuffer: invalid argument (cannot encode character '\56550')
Error: Process completed with exit code 1.

@fendor

fendor commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Right, that's a pity.

I am not sure how to fix this, we could skip it on platforms that don't support UTF-8 but a little unsure how?

@Bodigrim

Copy link
Copy Markdown
Collaborator

I suspect these CI images do not set locale to UTF-8. Which is unlikely to happen in real world, but pretty common for Docker images, trying to be minimal.

It's unclear to me what exactly fails. It could be either Unicode filenames themselves (perhaps check getFileSystemEncoding and skip tests if it's not UTF-8), or writing Unicode content into a file open in non-UTF-8 textual mode (not sure which part would do it, I think most of I/O goes through ByteString, which cannot throw such error), or maybe it just fails while outputing Unicode test name because terminal locale is off (hSetEncoding stdout or just sanitize test names to be ASCII only).

@fendor

fendor commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Looking into it

@fendor

fendor commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

What fails is the runghc command

cabal-testsuite/PackageTests/MultiRepl/Utf8-/cabal.test.hs             FAIL
$ /home/hugin/.ghcup/ghc/9.6.7/bin/runghc-9.6.7 -- '--ghc-arg=-i' '--ghc-arg=-hide-all-packages' '--ghc-arg=-no-user-package-db' '--ghc-arg=-package-db' '--ghc-arg=/home/hugin/.local/state/cabal/store/ghc-9.6.7/package.db' '--ghc-arg=-package-db' '--ghc-arg=/home/hugin/Documents/haskell/cabal/dist-newstyle/packagedb/ghc-9.6.7' '--ghc-arg=-package-id' '--ghc-arg=Cabal-3.19.0.0-inplace' '--ghc-arg=-package-id' '--ghc-arg=Cabal-hooks-3.19-inplace' '--ghc-arg=-package-id' '--ghc-arg=Cabal-syntax-3.19.0.0-inplace' '--ghc-arg=-package-id' '--ghc-arg=base-4.18.3.0' '--ghc-arg=-package-id' '--ghc-arg=bytestring-0.11.5.4' '--ghc-arg=-package-id' '--ghc-arg=cabal-testsuite-3-inplace' '--ghc-arg=-package-id' '--ghc-arg=containers-0.6.7' '--ghc-arg=-package-id' '--ghc-arg=directory-1.3.8.5' '--ghc-arg=-package-id' '--ghc-arg=exceptions-0.10.7' '--ghc-arg=-package-id' '--ghc-arg=filepath-1.4.301.0' '--ghc-arg=-package-id' '--ghc-arg=process-1.6.30.0-8830a9f8c9e81cebf4516dc99622173a5320f0a978e217e1bbd0c1ee237eb781' '--ghc-arg=-package-id' '--ghc-arg=time-1.12.2' '--ghc-arg=-package-id' '--ghc-arg=transformers-0.6.1.0' '--ghc-arg=-package-id' '--ghc-arg=unix-2.8.6.0' cabal-testsuite/PackageTests/MultiRepl/Utf8-/cabal.test.hs --builddir dist-newstyle/build/x86_64-linux/ghc-9.6.7/cabal-testsuite-3 cabal-testsuite/PackageTests/MultiRepl/Utf8-/cabal.test.hs --with-cabal /home/hugin/Documents/haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-9.14.1/cabal-install-3.19.0.0/x/cabal/build/cabal/cabal
stdout:

stderr:

<no location info>: error: [GHC-49196]
    Can't find cabal-testsuite/PackageTests/MultiRepl/Utf8-/cabal.test.hs

<interactive>:18:31: error: [GHC-76037]
    Not in scope: `Main.main'
    NB: no module named `Main' is imported.

Note, the cabal-testsuite/PackageTests/MultiRepl/Utf8-/cabal.test.hs, missing the UTF-8 code points.

Possible fixes:

The temporary directory should contain utf-8 characters on supported systems to test that cabal generally works with utf-8.
This should work for this particular issue, but might uncover many more unicode bugs in cabal.

It also makes sense (to me) to have a dedicated test for this particular regression.
We could skip the test if the system doesn't use UTF-8...

@fendor

fendor commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

This all seems incredibly tricky to get right... I started work on this in #12619, but everything keeps breaking...

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

Labels

merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge ready and waiting Mergify is waiting out the cooldown period

Projects

None yet

Development

Successfully merging this pull request may close these issues.

multi-repl crashes when the directory contains utf-8 symbols

5 participants