haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

`typecheck` shouldn't require network access

Open srid opened this issue 3 years ago • 7 comments

Is your enhancement request related to a problem? Please describe.

The typecheck command which is evoked when running haskell-language-server in the command line (so as to make sure that all files work with HLS) currently accesses the network via cabal. This makes it impossible to use with Nix, unless sandbox is disabled. See https://github.com/srid/haskell-flake/issues/21

default-hls-check> Severity: DsError
default-hls-check> Message:
default-hls-check>   Error when calling cabal exec -v0 -- ghc --print-libdir
default-hls-check>   dieVerbatim: user error (cabal: Couldn't establish HTTP connection. Possible cause: HTTP proxy
default-hls-check>   server
default-hls-check>   is down.
default-hls-check>   )

Describe the solution you'd like

Is there a way to make typecheck work without network access?

Describe alternatives you've considered

Using --option sandbox false in Nix, but this is obviously not a good idea.

srid avatar Aug 28 '22 22:08 srid

Hi, thank you for your bug report!

I don't know what's going wrong here exactly, but at least on my machine I don't require internet access for this command to succeed.

fendor avatar Aug 30 '22 10:08 fendor

cabal does have an --offline flag. I'm not sure if it would actually help, but it probably can't hurt to add it?

michaelpj avatar Aug 30 '22 16:08 michaelpj

It's hie-bios that is invoking Cabal, not HLS right? HLS knows nothing about Cabal

pepeiborra avatar Aug 30 '22 18:08 pepeiborra

It is hie-bios's tasks and the offline flag is useless for v2-* commands.

But I am not sure yet what the actual problem here is, like why it suddenly requires Internet.

fendor avatar Aug 30 '22 19:08 fendor

But I am not sure yet what the actual problem here is, like why it suddenly requires Internet.

cabal-install is a tool to automate Cabal builds by downloading dependencies from Hackage, so this is not surprising to me. A likely reason is that @srid's project uses Nix to provision all the dependencies in the global pkg database, but hie-bios wants to build the dependencies with a different set of flags and for that it needs to download the dist pacakges

pepeiborra avatar Aug 30 '22 19:08 pepeiborra

My view is that this is the expected behaviour, @srid should get in touch with the hie-bios maintainers if he wants to contribute patches to integrate hie-bios with Nix to somehow avoid these downloads

pepeiborra avatar Aug 30 '22 19:08 pepeiborra

@srid I think the core problem here is cabal doesn't trust nix installed binaries like build tools, so it's trying to cabal install them.

See https://github.com/haskell/cabal/issues/8434#issuecomment-1230889097 where I try to explain the nix workflow to cabal maintainers.

I think hie-bios only calls out to cabal and isn't responsible for network access.

ParetoOptimalDev avatar Sep 02 '22 04:09 ParetoOptimalDev