Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cabal treats url with trailing whitespace in import cabal.project file as a file path #10622

Open
theGhostJW opened this issue Dec 7, 2024 · 4 comments · May be fixed by #10629
Open

Cabal treats url with trailing whitespace in import cabal.project file as a file path #10622

theGhostJW opened this issue Dec 7, 2024 · 4 comments · May be fixed by #10629
Assignees
Labels
re: project-file Concerning cabal.project files type: bug

Comments

@theGhostJW
Copy link

Describe the bug

Cabal treats url with trailing whitespace in import cabal.project file as a file path

To Reproduce
Steps to reproduce the behavior:

When following along with: the users guide

  1. Add the following to the cabal.project file:
packages: .
import: https://www.stackage.org/nightly-2024-12-05/cabal.config 

Note: there is a trailing space at the end of the url

$ cabal build .

=> An error similar to the following is emitted:

/home/john-walker/repos/pyrethrum/https:/www.stackage.org/nightly-2024-12-05/cabal.config : withBinaryFile: does not exist (No such file or directory)
  1. delete the trailing white space.
  2. try build again
$ cabal build .

=> build proceeds as expected

Expected behavior

The current behaviour is confusing if you don't notice the white space. A better UX would be to:

  1. automatically trim the url OR
  2. emit a specific error pertaining to the trailing space

System information

  • Operating system: Ubuntu 24.04.1 LTS
  • cabal: cabal 3.12.1.0
  • ghc: GHC 9.8.4
@philderbeast
Copy link
Collaborator

I can reproduce this.

@philderbeast philderbeast added the re: project-file Concerning cabal.project files label Dec 7, 2024
@philderbeast
Copy link
Collaborator

We're relying on Network.URI.parseURI:

$ cabal repl cabal-install
...
ghci> import Network.URI
ghci> parseURI "https://www.stackage.org/nightly-2024-12-05/cabal.config"
Just https://www.stackage.org/nightly-2024-12-05/cabal.config
ghci> parseURI "https://www.stackage.org/nightly-2024-12-05/cabal.config "
Nothing

@philderbeast
Copy link
Collaborator

A string is a valid URL potentially surrounded by spaces if, after stripping leading and trailing whitespace from it, it is a valid URL.
W3C/HTML5/URLs

@philderbeast philderbeast self-assigned this Dec 7, 2024
@philderbeast philderbeast linked a pull request Dec 9, 2024 that will close this issue
6 tasks
@philderbeast
Copy link
Collaborator

I tested this on cabal-install versions; 3.8.1.0, 3.10.1.0, 3.10.2.0, 3.10.3.0 and 3.12.1.0. They all reported an error of "withBinaryFile: does not exist (No such file or directory)", something like this:

$ ~/.ghcup/bin/cabal build all --dry-run --project-file=cabal.tabs-and-spaces.project
/home/.../cabal/https://www.stackage.org/nightly-2024-12-05/cabal.config
: withBinaryFile: does not exist (No such file or directory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: project-file Concerning cabal.project files type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants