-
Notifications
You must be signed in to change notification settings - Fork 208
Could not obtain flags for test files with cabal-helper cradle using stack #1564
Comments
What is the content of the generated cabal file? |
It looks like this: cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.31.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: 0237d3eaa901762b9786046b053689250944bf6f8f5cd71ad3894e00fc5f5a72
name: mal
version: 0.1.0.0
description: Please see the README on GitHub at <https://github.com/githubuser/mal2#readme>
homepage: https://github.com/githubuser/mal2#readme
bug-reports: https://github.com/githubuser/mal2/issues
author: Author name here
maintainer: example@example.com
copyright: 2019 Author name here
license: BSD3
license-file: LICENSE
build-type: Simple
extra-source-files:
README.md
ChangeLog.md
source-repository head
type: git
location: https://github.com/githubuser/mal2
library
exposed-modules:
Eval
Lexer
Mal
Reader
Repl
Runtime
other-modules:
Paths_mal
hs-source-dirs:
src
build-depends:
base >=4.7 && <5
, haskeline
, hspec
, parsec
default-language: Haskell2010
executable mal-exe
main-is: Main.hs
other-modules:
Paths_mal
hs-source-dirs:
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, haskeline
, hspec
, mal
, parsec
default-language: Haskell2010
test-suite mal-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Helper
NumberSpec
Paths_mal
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, haskeline
, hspec
, mal
, parsec
default-language: Haskell2010
|
Can you maybe share the project so I can try, too? |
Sure, the repo is here. I am following this guide writing a lisp. |
I had the same error today with a simple servant project. When I ran the |
Same problem here, I'm able to reproduce this error with this project that contains test files. |
I am also facing same issue. |
Problem is related to stack. By default test-components are not in the global project definition, and executing cradle:
stack:
- path: ./test
component: "project:test:test-name"
- path: ./src
component: "project:lib"
... All available targets can be shown with |
My project is not using stack. I am facing this issue when running |
@prophet1906 You are running into the described problem and after running |
I wonder if we should not automatically construct this cradle, or its effect anyway. It seems it should be a straightforward generalisation, perhaps for when there is no |
I would argue that cabal-helper does exactly that, in a sophisticated way and true to the original build plan. In the original build plan, some components are not active or hidden by flags in the |
And what about change cabal-helper to configure/build the project with |
I like that idea, to make it at least configurable. |
I'm seeing this all over my codebase now, not just the tests. |
This is what I get as the actual error message
From what I can tell, it's not looking at the |
this is your library component. Can you share the resulting .cabal file? |
@fendor My full
|
Got same problem with a stack/hpack-based project, but for The project in question is here. Is there any workaround for this one? |
This error pops up like every second, it's annoying (I guess that it is the main problem, not the actual error?) So maybe there is a way, as a temporary solution, to just hide the error? Or to hide any errors in vscode. |
@0xd34df00d We are currently not supporting diagnostics for @kirillFedorov1 Unless you have the same issue as @0xd34df00d, you should not ignore this message, as it means that something can not be loaded. If you just want to ignore special files, take a look at https://github.com/haskell/haskell-ide-engine#project-configuration where you can specify that certain source files should not be loaded by hie. |
@fendor I wasn't trying to load |
@0xd34df00d Maybe you have opened it by accident before that? Requests to compile files are queued and executed in order. I can not imagine any other reason why else hie was trying to load |
@kirillFedorov1 You have to specify a cradle:
cabal:
- path: "./test/dispatcher/"
component: "test:dispatcher-test"
- path: "./test/functional/"
component: "test:func-test"
- path: "./test/unit/"
component: "test:unit-test"
- path: "./hie-plugin-api/"
component: "lib:hie-plugin-api"
- path: "./app/MainHie.hs"
component: "exe:hie"
- path: "./app/HieWrapper.hs"
component: "exe:hie-wrapper"
- path: "./"
component: "lib:haskell-ide-engine" And now you dont want to load any test files, you can do: cradle:
multi:
# Usual cradle for all paths
- path: ./
config:
cradle:
cabal:
- path: "./hie-plugin-api/"
component: "lib:hie-plugin-api"
- path: "./app/MainHie.hs"
component: "exe:hie"
- path: "./app/HieWrapper.hs"
component: "exe:hie-wrapper"
- path: "./"
component: "lib:haskell-ide-engine"
# None cradle, dont load any module in that folder
- path: ./test
config:
cradle:
none: |
@fendor I made a hie.yaml in my working root, now the error doesn't appear, but another message appears every time: |
Can you provide all logs please? For vscode, https://github.com/alanz/vscode-hie-server#investigating-and-reporting-problems |
@fendor I use stack, by the way. I have just realized that in
|
Then you have to change the component syntax and the tool at the top to |
@fendor Sorry I tried to figure out I swear
|
No need to apologize :) cradle:
multi:
# Usual cradle for all paths
- path: ./
config:
cradle:
stack:
- path: "./src/"
component: "exercises:lib"
# None cradle, dont load any module in that folder
- path: "./test"
config:
cradle:
none: This means that your library component is located in the directory "src" and that you do not want to load anything that is in the "./test" directory. |
@fendor it still doesn't work.
|
The |
The |
@jneira should I just put |
No, sorry for not being precise, i wanted to mean that |
@jneira Yes, the same error appears in the hie log and in the console.
|
@kirillFedorov1 So with I guess |
@jneira "user" is the real name |
It seems the error is thrown in ghc: https://github.com/ghc/ghc/blob/92b6a0237e0195cee4773de4b237951addd659d9/compiler/main/SysTools/BaseDir.hs#L153-L157 |
If it helps: |
A workaround for this issue, without an explicit hie.yaml is to add:
to |
And what is the workaround here? I'm a bit lost on all those comments. |
Yeah, you are right, the possible workarounds are:
|
I am also getting these errors with a cabal project:
This is the project/commit for which I am getting the errors: https://github.com/fairy-tale-agi-solutions/haskell-editor-setup/tree/d6c890b33f8dd7bec4cae07e9236a923fb5bd42c |
Everything was working well until I recompiled HIE with commit hash 22c69c620b2707119194bb33c4ae15427e46f0a2. When I try editing a test file, vscode keeps complaining the following:
Previously (at least in November 2019) I never met this, but now vscode warns me that
Fail on initialisation for "/Users/xiao/haskell/mal2/test/NumberSpec.hs". Could not obtain flags for: "test/NumberSpec.hs".
repeatedly. (The alert flashes so quickly that I narrowly copied this line).stack test
works correctly and the test source dir is specified in thetests
section ofpackage.yaml
(The same problem occurs even if I initialize a new project withstack
). It seems that HIE doesn't consider test sources as a component to be aware of.The text was updated successfully, but these errors were encountered: