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

--offline does not stop Cabal from attempting to access the network #10288

Open
9999years opened this issue Aug 27, 2024 · 5 comments
Open

--offline does not stop Cabal from attempting to access the network #10288

9999years opened this issue Aug 27, 2024 · 5 comments

Comments

@9999years
Copy link
Collaborator

Describe the bug

Cabal attempts to access the network, even if --offline is given.

To Reproduce

$ rm -rf dist-newstyle/ ~/.cabal/packages && cabal exec -v --offline -- ghc --print-libdir
...
Trying to locate mirrors via DNS for initial bootstrap of secure repository
'http://hackage.haskell.org/' ...
located 2 mirrors for http://hackage.haskell.org/ :
- http://hackage.fpcomplete.com/
- http://objects-us-east-1.dream.io/hackage-mirror/
Selected mirror http://hackage.haskell.org/
Downloading root
Including the following directories in PATH:
- /Users/wiggles/.cabal/bin
Running: /nix/store/c8zjxnirrs9w62rh5mnzd54rx9w31zai-curl-8.9.0-bin/bin/curl 'http://hackage.haskell.org/root.json' --output /tmp/nix-shell.HDXhum/transportAdapterGet36559-3 --location --write-out '%{http_code}' --user-agent 'cabal-install/3.12.1.0 (osx; aarch64)' --silent --show-error --dump-header /tmp/nix-shell.HDXhum/curl-headers36559-4.txt
...

Expected behavior

If --offline is set, Cabal should not attempt to access the network.

System information

Operating system: macOS Sonoma 14.6.1 (23G93)

$ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.3
@ulysses4ever
Copy link
Collaborator

Prior issue: #8752. I believe it was fixed by #8676 for the build command but exec was never looked at perhaps.

@9999years
Copy link
Collaborator Author

@ulysses4ever No, cabal build -v2 --offline shows the exact same curl invocation.

@ulysses4ever
Copy link
Collaborator

Oh, good catch! Then it's a new revelation, and we need to fix it!

I can't reproduce your issue neither with exec nor with build though. What context are you calling cabal from? Any project files involved? Here's what I see with a clean package:

cabal init -nm --lib
...rm -rf dist-newstyle/ ~/.cabal/packages && cabal-3.12.1.0 exec -v --offline -- ghc --print-libdir
Project settings changed, reconfiguring...
creating /home/artem/Dev/tmp/dist-newstyle
creating /home/artem/Dev/tmp/dist-newstyle/cache
Compiler settings changed, reconfiguring...
Running: /run/current-system/sw/bin/ghc --numeric-version
looking for tool ghc-pkg near compiler in /run/current-system/sw/bin
found ghc-pkg in
/nix/store/j7pf2p2dpyi7psvmgm6aqyqm7iqwbfz8-ghc-9.6.5/bin/ghc-pkg-9.6.5
Running: /nix/store/j7pf2p2dpyi7psvmgm6aqyqm7iqwbfz8-ghc-9.6.5/bin/ghc-pkg-9.6.5 --version
Running: /run/current-system/sw/bin/ghc --supported-languages
Running: /run/current-system/sw/bin/ghc --info
Running: /run/current-system/sw/bin/ghc --print-global-package-db
Reading available packages of hackage.haskell.org...
Using most recent state specified from most recent cabal update
index-state(hackage.haskell.org) = 2024-08-27T15:07:51Z
Failed to query pkg-config, Cabal will continue without solving for pkg-config
constraints: Cannot find pkg-config program
Resolving dependencies...
Component graph for tmp-0.1.0.0: component lib
component tmp-0.1.0.0-inplace include base-4.18.2.1
unit tmp-0.1.0.0-inplace
    include base-4.18.2.1
    MyLib=tmp-0.1.0.0-inplace:MyLib
creating /home/artem/Dev/tmp/dist-newstyle/tmp
Running: /run/current-system/sw/bin/ghc --print-libdir
/nix/store/j7pf2p2dpyi7psvmgm6aqyqm7iqwbfz8-ghc-9.6.5/lib/ghc-9.6.5/lib

Without any package available, it just errors citing no package (which may be not the best idea but that's another issue):

❯ rm -rf dist-newstyle/ ~/.cabal/packages && cabal-3.12.1.0 exec -v --offline -- ghc --print-libdir
Project settings changed, reconfiguring...
No cabal.project file or cabal file matching the default glob './*.cabal' was found.
Please create a package description file <pkgname>.cabal or a cabal.project file referencing the packages you want to build.

@9999years
Copy link
Collaborator Author

Where is your cabal reading this index from? Maybe it's not ~/.cabal/packages on your machine.

Using most recent state specified from most recent cabal update
index-state(hackage.haskell.org) = 2024-08-27T15:07:51Z

On both my Linux and macOS machines those commands error in the cabal init -nm --lib, so I'm not sure.

@ulysses4ever
Copy link
Collaborator

Ah, sorry about that: it's the XDG stuff. https://cabal.readthedocs.io/en/stable/config.html#directories

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