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

"Could not find module" error due to bad cradle root dir #299

Closed
ratanakkim opened this issue Aug 9, 2020 · 5 comments
Closed

"Could not find module" error due to bad cradle root dir #299

ratanakkim opened this issue Aug 9, 2020 · 5 comments

Comments

@ratanakkim
Copy link

ratanakkim commented Aug 9, 2020

Getting could not find module despite successful build with packages. The module is QuickCheck
QuickCheck import
Failed to find modules

package.yaml :

executables:
  wk4-exe:
    main: wk4.hs
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - QuickCheck

stack.yaml :

resolver: lts-14.27

packages:
- .

extra-deps: 
- QuickCheck-2.13.2
@lukel97
Copy link
Collaborator

lukel97 commented Aug 9, 2020

Can you output the contents of the Haskell tab from the Output window in VS Code?

@ratanakkim
Copy link
Author

Can you output the contents of the Haskell tab from the Output window in VS Code?

[client] run command: "C:\Users\Ratanak\AppData\Roaming\local\bin\haskell-language-server.exe --lsp -d -l C:\Users\Ratanak\AppData\Roaming\local\bin\logs2.txt"
[client] debug command: "C:\Users\Ratanak\AppData\Roaming\local\bin\haskell-language-server.exe --lsp -d -l C:\Users\Ratanak\AppData\Roaming\local\bin\logs2.txt"
[client] server cwd: undefined
haskell-language-server version: 0.2.2.0 (GHC: 8.6.5) (PATH: C:\Users\Ratanak\AppData\Roaming\local\bin\haskell-language-server.exe) (GIT hash: d74d1113d37125a69e25e8cf9f0a8244b3c0d673)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "C:\\Users\\Ratanak\\AppData\\Roaming\\local\\bin\\logs2.txt", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell"]
  in directory: f:\Users\Ratanak\School\UNI\CS3141_2020
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.05s
Output from setting up the cradle Cradle {cradleRootDir = "f:\\Users\\Ratanak\\School\\UNI\\CS3141_2020", cradleOptsProg = CradleAction: Default}

@fendor
Copy link
Collaborator

fendor commented Aug 10, 2020

The project discovery has failed you!
Let's take a look at the cradle: (which tells hls where your root directory is and which tool (cabal/stack) it should use to load your project)

Cradle 
  { cradleRootDir = "f:\\Users\\Ratanak\\School\\UNI\\CS3141_2020"
  , cradleOptsProg = CradleAction: Default
  }

Is the path "f:\\Users\\Ratanak\\School\\UNI\\CS3141_2020" the root of your project? Is your stack.yaml in the same directory?
The record cradleOptsProg should have the value CradleAction: Stack, that's how you know it configures your project correctly!

On windows, I usually use Open Folder and open exactly the folder that contains my project.

@ratanakkim
Copy link
Author

The project discovery has failed you!
Let's take a look at the cradle: (which tells hls where your root directory is and which tool (cabal/stack) it should use to load your project)

Cradle 
  { cradleRootDir = "f:\\Users\\Ratanak\\School\\UNI\\CS3141_2020"
  , cradleOptsProg = CradleAction: Default
  }

Is the path "f:\\Users\\Ratanak\\School\\UNI\\CS3141_2020" the root of your project? Is your stack.yaml in the same directory?
The record cradleOptsProg should have the value CradleAction: Stack, that's how you know it configures your project correctly!

On windows, I usually use Open Folder and open exactly the folder that contains my project.

No it is not. It is a few more folders in. I will try to replicate the open folder.
But I found a workaround by having a hie.yaml in the root of the project folder.

@jneira jneira changed the title "Could not find module" Error "Could not find module" error due to bad cradle root dir Aug 16, 2020
@jneira
Copy link
Member

jneira commented Nov 17, 2020

It seems this is not a bug. but hie-bios behaviour, so i am gonna close it. @ratanakkim please reopen if you think something could be improved

@jneira jneira closed this as completed Nov 17, 2020
pepeiborra added a commit that referenced this issue Dec 27, 2020
* Smarter logic to remove redundant import bindings

The new code finds the spans to remove using the GHC parse tree, then manually
extends them to include commas/spaces.

Fixes #299

* Compatibility with GHC 8.4

* Improve comment

Co-Authored-By: Andreas Herrmann <[email protected]>

* Use breakOnEnd in unqualify

This will handle A.foo as well as A.B.foo

Co-authored-by: Andreas Herrmann <[email protected]>
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

5 participants