rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 94 forks source link

Couldn't create Haskell module because Cabal file can't be found #589

Closed ForNeVeR closed 4 years ago

ForNeVeR commented 4 years ago

I am setting up a fresh machine, have installed Stack (and made sure it's in the PATH), IDEA 2020.2 Beta (because I like living on the edge), and the latest IntelliJ Haskell plugin (v. 1.0.0-beta76).

After trying to import a Stack project, I am being presented with the following error:

Couldn't create Haskell module because Cabal file can't be found in W:\Projects\icfpc-2020

After that, an informational message is shown:

Can not add package . as module because W:\Projects\icfpc-2020 does not contain Cabal file or Cabal file can not be parsed

I can't share the project (yet), because it's part of my ICFP Contest submission (and will be available in a couple of days), but it's a pretty standard Stack package - with no Cabal file.

rikvdkleij commented 4 years ago

The plugin expects a Cabal file, it's a prerequisite.

ForNeVeR commented 4 years ago

But Stack will generate it automatically on stack build, couldn't we execute it ourselves on initial import?

rikvdkleij commented 4 years ago

When a Haskell project is opened, the first action of plugin is to build the project which generates the cabal file from package.yaml. So I don’t understand the issue.

ForNeVeR commented 4 years ago

And now I understand the issue :)

GHC installation on my machine was broken due to unfortunate https://gitlab.haskell.org/ghc/ghc/-/issues/17926

So, is it possible that during the first build, we don't check the stack exit code, and try to import the project anyway? Or maybe it is even by design?

rikvdkleij commented 4 years ago

and try to import the project anyway? Or maybe it is even by design?

Well, a compile error is no reason to not open or import the project.

ForNeVeR commented 4 years ago

Alright, so this was a corner case, only valid when a project cannot be compiled. Fair enough, in such a case I'll close the issue. Thanks for explanation!

astrolemonade commented 3 years ago

That happened to me because the Stack executable was not found, mine is in /usr/bin/stack but the extension looks into /usr/local/bin/stack so I created that directory and created a symbolic link using sudo ln -s /usr/bin/stack /usr/local/bin/stack and now it works without problems