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

Using ~ in remote-repo-cache crashes cabal update and isn't recognised by cabal build #10380

Open
j-mie6 opened this issue Sep 20, 2024 · 5 comments

Comments

@j-mie6
Copy link

j-mie6 commented Sep 20, 2024

Describe the bug
Having a cabal.project file with remote-repo-cache: ~/.cache/cabal/my-packages breaks cabal update, with the following error:

cabal update
Downloading the latest package list from hackage.haskell.org
~/.cache/cabal/my-packages/hackage.haskell.org/01-index.timestamp: withFile: does not exist (No such file or directory)

specifying as /home/jamie/.cache/cabal/my-packages works just fine with cabal update. Having done this, switching back to ~/ instead of /home/jamie/ produces the following for cabal build:

Error: [Cabal-7160]
The package list for 'hackage.haskell.org' does not exist. Run 'cabal update' to download it.

This seems to affect cabal versions from at least as far back as 3.10.1.0, I also tested with 3.10.3.0 and 3.12.1.0 with the same issue.

@j-mie6
Copy link
Author

j-mie6 commented Sep 20, 2024

the same applies, it seems, for the --local-repo-cache flag too.

@j-mie6 j-mie6 changed the title Using ~ in local-repo-cache crashes cabal update and isn't recognised by cabal build Using ~ in remote-repo-cache crashes cabal update and isn't recognised by cabal build Sep 20, 2024
@geekosaur
Copy link
Collaborator

~ is a shell-ism, and programs have to do extra work to support it. At which point the question becomes whether to also support other shell-isms (~user, $envar, etc.). Most programs punt on it, aside from e.g. editors and such.

@j-mie6
Copy link
Author

j-mie6 commented Sep 20, 2024

In which case, there needs to be some way of specifying the home directory in the configuration here! But presumably, whatever is doing the file I/O code-side should just be using native APIs that do understand ~, no? I'm pretty sure I can use ~ in regular file I/O right (if not I certainly can in other languages!)

@geekosaur
Copy link
Collaborator

geekosaur commented Sep 20, 2024

Some languages support it (e.g. Perl), others do not (e.g. C/C++, Java). There is no native API that supports it, except in convenience-oriented languages that specifically support shell-isms. (Try something like cat ~/foo vs. cat '~/foo'.)

@j-mie6
Copy link
Author

j-mie6 commented Sep 20, 2024

That's true, but in Java, say, you can use System.getProperty("user.home") to fetch it, perhaps if cabal is running in a UNIX environment it can take a leading ~ on a path and lookup the appropriate home?

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

No branches or pull requests

2 participants