Skip to content

Program error: Failed to load interface for ‘Main’ no unit id matching ‘main’ was found #204

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

Closed
d-xo opened this issue Jul 15, 2020 · 11 comments · Fixed by #1435
Closed
Labels
os: nixos type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@d-xo
Copy link

d-xo commented Jul 15, 2020

I have this error in the main executable file in a two projects (hevm, and act).

In both of these projects haskell-language-server works very well (type checking / doc lookup / jump to definition) in all files except the main executable (Main.hs in act and hevm-cli.hs in hevm).

cabal new-build works without errors in both projects.

I am using a globally installed version of hakell-language-server built against ghc8.6.5 using the nix deritvations here.

The full output from running haskell-language-server from the root of the act repo is here.

If you want to reproduce the issue locally, it's probably easiest to use the act project. The shell.nix in the repo root can be used to prepare a working build environment, but does not currently include an installation of haskell-language-server itself.

@d-xo d-xo changed the title Program error: Failed to load interface for ‘Main’no unit id matching ‘main’ was found Program error: Failed to load interface for ‘Main’ no unit id matching ‘main’ was found Jul 15, 2020
@jneira jneira added os: nixos status: needs repro type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jul 15, 2020
@d-xo
Copy link
Author

d-xo commented Aug 13, 2020

The issue was missing module Main where declarations. Seems obvious in retrospect although it is quite confusing that cabal doesn't seem to need them.

@d-xo d-xo closed this as completed Aug 13, 2020
@fendor
Copy link
Collaborator

fendor commented Aug 13, 2020

Hey! I have encountered the same issue, the reason is GHC will auto-insert the module declaration (if it is missing) and add Main.hs to the unit main. Then it looks up the unit, and can't find it, hence the error.
I say we keep this issue open because it should not fail with this error message since cabal accepts it.

Earlier today, I actually looked into your repo's since I had the suspicion regarding module declarations but in the linked repo, the module declaration was present. Did you change that locally or something?

@fendor fendor reopened this Aug 13, 2020
@d-xo
Copy link
Author

d-xo commented Aug 14, 2020

I added the module Main where declarations yesterday

@jneira
Copy link
Member

jneira commented Sep 23, 2020

I cant reproduce with lastest hls and a Main module without the header, @xwvvvvwx could you confirm it it is fixed for you too?

@jneira jneira added status: needs info Not actionable, because there's missing information and removed status: needs repro labels Sep 23, 2020
@d-xo
Copy link
Author

d-xo commented Sep 24, 2020

I can still reproduce with haskell-language-server 0.4.0.0 from nixpkgs.

@jneira jneira removed the status: needs info Not actionable, because there's missing information label Sep 24, 2020
@jneira
Copy link
Member

jneira commented Sep 24, 2020

Thanks for checking it again, it is possible that the os could be related (i am on windows) but i assumed that it should not be.
@fendor could that make sense?

@fendor
Copy link
Collaborator

fendor commented Sep 24, 2020

No, it is close to impossible that the OS is related. I will check if I can still reproduce it and if it is actually what I think it is.

@jneira
Copy link
Member

jneira commented Sep 24, 2020

I've just double check it with ghc-8.10.1 (my previous test was with ghc-8.8.3), a main module without the header:

imagen

No error in the log.

@jneira
Copy link
Member

jneira commented Mar 21, 2021

@fendor did you have the opportunity of checking if it is reproduced?

@fendor
Copy link
Collaborator

fendor commented Mar 22, 2021

I can't reproduce it anymore and furthermore, I would expect #1435 fixes it for good, too.

@jneira jneira linked a pull request Mar 22, 2021 that will close this issue
@jneira
Copy link
Member

jneira commented Mar 22, 2021

@fendor nice, thanks for confirming it
@xwvvvvwx feel freeto reopen if you continue experienced the issue

@jneira jneira closed this as completed Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os: nixos type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants