Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Could not obtain flags for test files with cabal-helper cradle using stack #1564

Open
fduxiao opened this issue Jan 7, 2020 · 56 comments
Open

Comments

@fduxiao
Copy link

fduxiao commented Jan 7, 2020

Everything was working well until I recompiled HIE with commit hash 22c69c620b2707119194bb33c4ae15427e46f0a2. When I try editing a test file, vscode keeps complaining the following:

Fail on initialisation for "/Users/xiao/haskell/mal2/test/NumberSpec.hs".
Could not obtain flags for: "test/NumberSpec.hs".

This module was not part of any component we are aware of.

Component: ChLibName ChMainLibName with source directory: ["src"]
Component: ChExeName "mal-exe" with source directory: ["app"]


To expose a module, refer to:
https://docs.haskellstack.org/en/stable/GUIDE/
If you are using `package.yaml` then you don't have to manually expose modules.
Maybe you didn't set the source directories for your project correctly.

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 the tests section of package.yaml(The same problem occurs even if I initialize a new project with stack). It seems that HIE doesn't consider test sources as a component to be aware of.

@fendor
Copy link
Collaborator

fendor commented Jan 7, 2020

What is the content of the generated cabal file?

@fduxiao
Copy link
Author

fduxiao commented Jan 7, 2020

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

@fendor
Copy link
Collaborator

fendor commented Jan 8, 2020

Can you maybe share the project so I can try, too?

@fduxiao
Copy link
Author

fduxiao commented Jan 8, 2020

Sure, the repo is here. I am following this guide writing a lisp.

@srahmi
Copy link

srahmi commented Jan 9, 2020

I had the same error today with a simple servant project. When I ran the stack test command the error seem to be disappeared

@vaclavsvejcar
Copy link

Same problem here, I'm able to reproduce this error with this project that contains test files.

@prophet1906
Copy link

I am also facing same issue.

@fendor
Copy link
Collaborator

fendor commented Jan 15, 2020

Problem is related to stack. By default test-components are not in the global project definition, and executing stack test enables test components. That is why stack test does solve that problem.
Another possible work-around is to use an explicit hie.yaml

cradle:
  stack:
    - path: ./test
      component: "project:test:test-name"
    - path: ./src
      component: "project:lib"
    ...

All available targets can be shown with stack ide targets.

@prophet1906
Copy link

Problem is related to stack. By default test-components are not in the global project definition, and executing stack test enables test components. That is why stack test does solve that problem.
Another possible work-around is to use an explicit hie.yaml

cradle:
  stack:
    - path: ./test
      component: "project:test:test-name"
    - path: ./src
      component: "project:lib"
    ...

All available targets can be shown with stack ide targets.

My project is not using stack. I am facing this issue when running cabal test.

@fendor
Copy link
Collaborator

fendor commented Jan 15, 2020

@prophet1906 You are running into the described problem and after running cabal test, the problem is solved? Do you have any special changes in your cabal project?
On my test project using cabal, I can load test-files.

@alanz
Copy link
Collaborator

alanz commented Jan 15, 2020

Problem is related to stack. By default test-components are not in the global project definition, and executing stack test enables test components. That is why stack test does solve that problem.
Another possible work-around is to use an explicit hie.yaml

cradle:
  stack:
    - path: ./test
      component: "project:test:test-name"
    - path: ./src
      component: "project:lib"
    ...

All available targets can be shown with stack ide targets.

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 hie.yaml.

@fendor
Copy link
Collaborator

fendor commented Jan 15, 2020

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 *.cabal file.

@jneira
Copy link
Member

jneira commented Jan 16, 2020

And what about change cabal-helper to configure/build the project with --test --bench --no-run-tests --no-run-benchmarks here: https://github.com/DanielG/cabal-helper/blob/5b6cefdbe03ebc4ec6451751fbaba72cab663766/lib/Distribution/Helper.hs#L522-L531?

@fendor
Copy link
Collaborator

fendor commented Jan 16, 2020

And what about change cabal-helper to configure/build the project with --test --bench --no-run-tests --no-run-benchmarks

I like that idea, to make it at least configurable.

@tuomohopia
Copy link

I'm seeing this all over my codebase now, not just the tests.

@tuomohopia
Copy link

This is what I get as the actual error message

2020-01-19 11:54:16.3609472 [ThreadId 103] - Fail on cradle initialisation: (ExitFailure 2)["Could not obtain flags for: \"src\\schema\\AnswerChoice.hs\".","","This module was not part of any component we are aware of.","","Component: ChLibName ChMainLibName with source directory: [\"src\",\"src/schema\",\"src/api\",\"src/Questions\",\"src/Users\"]","Component: ChExeName \"healthbot-api-exe\" with source directory: [\"app\"]","Component: ChExeName \"migrations\" with source directory: [\"migrations\"]","","","To expose a module, refer to:","https://docs.haskellstack.org/en/stable/GUIDE/","If you are using `package.yaml` then you don't have to manually expose modules.","Maybe you didn't set the source directories for your project correctly."]
2020-01-19 11:54:16.361947 [ThreadId 38] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "Fail on initialisation for \"D:\\dev\\healthbot\\healthbot-api\\src\\schema\\AnswerChoice.hs\". Could not obtain flags for: \"src\\schema\\AnswerChoice.hs\".", ideInfo = Null} with mid: Nothing

From what I can tell, it's not looking at the library in my cabal file, where the module is exposed.

@fendor
Copy link
Collaborator

fendor commented Jan 19, 2020

@tuomohopia

ChLibName ChMainLibName with source directory: [\"src\",\"src/schema\",\"src/api\",\"src/Questions\",\"src/Users\"]

this is your library component. Can you share the resulting .cabal file?
I thought that multiple source directories are invalid, so maybe we are not covering this case.

@tuomohopia
Copy link

@fendor My full .cabal file looks like this

-- This file has been generated from package.yaml by hpack version 0.31.1.
--
-- see: https://github.com/sol/hpack
--
-- hash: 8313da4611145f153645f4cdd683b1e59fa8a667a9a62f5484494f7a39934dfd

name:           healthbot-api
cabal-version:  >= 1.8
version:        0.1.0.0
description:    Please see the README on GitHub at <https://github.com/tuomohopia/healthbot-api#readme>
homepage:       https://github.com/tuomohopia/healthbot-api#readme
bug-reports:    https://github.com/tuomohopia/healthbot-api/issues
author:         Tuomo Hopia
maintainer:     tuomo.hopia@gmail.com
copyright:      2019 Tuomo Hopia
build-type:     Simple
extra-source-files:
    README.md
    ChangeLog.md

source-repository head
  type: git
  location: https://github.com/tuomohopia/healthbot-api

library
  default-language: Haskell2010
  exposed-modules:
      Lib
      , Config
      , Geolocation
      , AnswerChoice
      -- , QuestionBattery
      , Helpers
      , Gender
      , Api
      , ApiDocs
      -- , RootEndpoint
      , Auth
      , Schema
      , Database.Database
      , Database.Setup
      -- Users:
      , Users.Types
      , UsersEndpoint
      , Database.Query.Users
      -- Questions:
      , Questions.Types
      , QuestionsEndpoint
      , Database.Query.Questions
      -- Answers:
      , Answers.Types
      , Answers.AnswerMapping
      , AnswersEndpoint
      , Database.Query.Answers
      -- Next Questions
      , Nexts.QuestionBattery
  other-modules:
      Paths_healthbot_api
  hs-source-dirs:
      src
      , src/schema
      , src/api
      , src/Questions
      , src/Users
  build-depends:
      base >=4.7 && <5
      , text
      , time
      , aeson
      , mtl
      , bytestring
      , containers >=0.6.0.1
      , persistent-database-url
      , envy
      , transformers
      , monad-logger
      , servant
      , servant-server
      , servant-docs
      , wai
      , warp
      , email-validate
      , servant-auth
      , servant-auth-server
      , servant-auth-docs
      , servant-swagger
      , servant-auth-swagger
      , swagger2
      , jose
      , cookie
      , persistent-postgresql
      , squeal-postgresql
      , postgresql-binary
      , generics-sop
      , resource-pool
      , lens
      , aeson-pretty

executable healthbot-api-exe
  main-is: Main.hs
  other-modules:
      Paths_healthbot_api
  exposed-modules:
      Main
  hs-source-dirs:
      app
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , healthbot-api
    , mtl
    , text
    , aeson
    , persistent
    , persistent-postgresql
    , persistent-template
    , monad-logger
    , time
    , transformers
    , containers >=0.6.0.1
    , envy
    , bytestring
    , wai
    , warp
    , persistent-database-url
    , servant
    , servant-server
    , servant-auth
    , servant-auth-server
  default-language: Haskell2010

executable migrations
  main-is: Main.hs
  other-modules:
      Paths_healthbot_api
  hs-source-dirs:
      migrations
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , healthbot-api
    , mtl
    , text
    , persistent
    , persistent-postgresql
    , monad-logger
    , transformers
    , containers >=0.6.0.1
    , envy
    , bytestring
    , persistent-database-url
  default-language: Haskell2010

test-suite unit-tests
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  other-modules:
      Paths_healthbot_api, ConfigSpec, SeedData, SeedHelpers
  hs-source-dirs:
      test
      , test/unit
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , healthbot-api
    , mtl
    , text
    , aeson
    , persistent
    , persistent-postgresql
    , persistent-template
    , monad-logger
    , time
    , transformers
    , containers >=0.6.0.1
    , envy
    , hspec
    , hspec-wai
    , bytestring
    , hspec-discover
    , wai
    , warp
    , servant-client
    , http-client
    , http-types
  default-language: Haskell2010

test-suite integration-tests
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  other-modules:
      Paths_healthbot_api, SeedHelpers, SeedHelpers, TestHelpers, SeedData, UsersEndpointSpec, QuestionsEndpointSpec, AnswersEndpointSpec
  hs-source-dirs:
      test
      , test/integration
      , app
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , healthbot-api
    , mtl
    , text
    , aeson
    , persistent
    , persistent-postgresql
    , persistent-template
    , persistent-database-url
    , monad-logger
    , time
    , transformers
    , containers >=0.6.0.1
    , envy
    , hspec
    , hspec-wai
    , hspec-wai-json
    , bytestring
    , hspec-discover
    , hspec-expectations-lifted
    , wai
    , warp
    , servant
    , servant-server
    , servant-client
    , http-client
    , http-types
    , servant-auth
    , servant-auth-server
    , servant-auth-client
    , jose
  default-language: Haskell2010

@0xd34df00d
Copy link

Got same problem with a stack/hpack-based project, but for Setup.hs (the one for test files indeed goes away after doing stack test):

2020-02-09 18:48:25.020555898 [ThreadId 4] - Fail on cradle initialisation: (ExitFailure 2)["Could not obtain flags for: "Setup.hs".","","This module was not part of any component we are aware of.","","Component: ChLibName ChMainLibName with source directory: ["src"]","Component: ChExeName "hwc-exe" with source directory: ["app"]","Component: ChTestName "hwc-test" with source directory: ["test"]","","","To expose a module, refer to:","https://docs.haskellstack.org/en/stable/ GUIDE/","If you are using package.yaml then you don't have to manually expose modules.","Maybe you didn't set the source directories for your project correctly."]

The project in question is here. Is there any workaround for this one?

@kirillFedorov1
Copy link

kirillFedorov1 commented Feb 10, 2020

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.

@fendor
Copy link
Collaborator

fendor commented Feb 10, 2020

@0xd34df00d We are currently not supporting diagnostics for Setup.hs. E.g. we can not load this into the IDE.

@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.

@0xd34df00d
Copy link

@fendor I wasn't trying to load Setup.hs, this appeared when I tried to open the usual app/Main.hs. Sorry for omitting that!

@fendor
Copy link
Collaborator

fendor commented Feb 10, 2020

@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 Setup.hs if you didnt open it explicitly yourself

@fendor
Copy link
Collaborator

fendor commented Mar 15, 2020

@kirillFedorov1 You have to specify a none - cradle.
Given this hie.yaml

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:

@kirillFedorov1
Copy link

@fendor I made a hie.yaml in my working root, now the error doesn't appear, but another message appears every time: Saving 'tests.hs': Running 'Haskell Language Server' Formatter (configure). And it seems something happened with my autosave setting.

@fendor
Copy link
Collaborator

fendor commented Mar 16, 2020

Can you provide all logs please? For vscode, https://github.com/alanz/vscode-hie-server#investigating-and-reporting-problems

@kirillFedorov1
Copy link

kirillFedorov1 commented Mar 16, 2020

@fendor I use stack, by the way. I have just realized that in hie.yaml you provided cabal is used.

2020-03-16 11:55:39.1848944 [ThreadId 8] - Command `ghc --print-libdir` failed.

2020-03-16 11:55:39.1848944 [ThreadId 8] - Could not obtain the libdir.

Using hie version: Version 1.0.0.0, Git revision 4bec07d79cf77c8ee855957d20e315a89f799d75 (3745 commits) x86_64 ghc-8.6.5

2020-03-16 11:55:39.1868945 [ThreadId 8] - Scheduler thread exited unexpectedly: hie.exe: panic! (the 'impossible' happened)
  (GHC version 8.6.5 for x86_64-unknown-mingw32):
	can't decompose ghc.exe path: "C:\\Users\\user\\AppData\\Roaming\\local\\bin\\hie.exe"

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

@fendor
Copy link
Collaborator

fendor commented Mar 16, 2020

Then you have to change the component syntax and the tool at the top to stack.
For stack components, see the command stack ide targets

@kirillFedorov1
Copy link

@fendor Sorry I tried to figure out I swear
So stack ide targets gives me exercises:lib, exercises:test:tests
How should hie.yaml look? This is wrong:

cradle:
  multi:
# Usual cradle for all paths
    - path: ./
      config:
        cradle:
          stack:
          - path: "./hie-plugin-api/"
            component: "exercises:lib:hie-plugin-api"
          - path: "./app/MainHie.hs"
            component: "exercises:lib:hie"
          - path: "./app/HieWrapper.hs"
            component: "exercises:lib:hie-wrapper"
          - path: "./"
            component: "exercises:lib:haskell-ide-engine"

# None cradle, dont load any module in that folder
    - path: ./test
      config:
        cradle:
          none:

@fendor
Copy link
Collaborator

fendor commented Mar 16, 2020

No need to apologize :)
I think it looks already almost correct, Ill take a stab in the dark and suggest it should look like this:

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.
If this does still not work, would you mind showing the output of invoking hie --debug . in the root of your project?

@kirillFedorov1
Copy link

@fendor it still doesn't work.

Running HIE(hie)
  Version 1.0.0.0, Git revision 4bec07d79cf77c8ee855957d20e315a89f799d75 (3745 commits) x86_64 ghc-8.6.5
To run as a LSP server on stdio, provide the '--lsp' argument
Current directory:D:\ssd-data\work\exercises

args:["--debug","."]

Looking for project config cradle...

2020-03-16 16:34:08.8436322 [ThreadId 3] - Found "D:\ssd-data\work\exercises\hie.yaml" for "D:\ssd-data\work\exercises\File.hs"
2020-03-16 16:34:08.9436379 [ThreadId 3] - Module "D:\ssd-data\work\exercises\File.hs" is loaded by Cradle: Cradle {cradleRootDir
= "D:\\ssd-data\\work\\exercises", cradleOptsProg = CradleAction: Stack}
2020-03-16 16:34:08.9746397 [ThreadId 3] - Executing Stack GHC with args: --numeric-version
2020-03-16 16:34:09.9176936 [ThreadId 3] - GHC Output: "Just "8.6.5""
2020-03-16 16:34:09.9296943 [ThreadId 3] - Executing Stack GHC with args: --print-libdir
2020-03-16 16:34:10.8147449 [ThreadId 3] - GHC Output: "Just "C:\\Users\\user\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\lib""


###################################################

Cradle: Stack project
Project Ghc version: 8.6.5
Libdir: Just "C:\\Users\\user\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\lib"
Searching for Haskell source files...
Found 4 Haskell source files.

###################################################

Found the following files:

D:\ssd-data\work\exercises\tests\tests.hs
D:\ssd-data\work\exercises\src\Exercises.hs
D:\ssd-data\work\exercises\Setup.hs
D:\ssd-data\work\exercises\app\Main.hs


Load them all now. This may take a very long time.

2020-03-16 16:34:10.9117505 [ThreadId 3] - New cradle: D:\ssd-data\work\exercises\tests\tests.hs
2020-03-16 16:34:10.9157507 [ThreadId 3] - Found "D:\ssd-data\work\exercises\hie.yaml" for "D:\ssd-data\work\exercises\tests\tests.hs"
2020-03-16 16:34:10.9267513 [ThreadId 3] - Module "D:\ssd-data\work\exercises\tests\tests.hs" is loaded by Cradle: Cradle {cradleRootDir = "D:\\ssd-data\\work\\exercises", cradleOptsProg = CradleAction: Stack}
2020-03-16 16:34:10.9277514 [ThreadId 3] - Found cradle: Cradle {cradleRootDir = "D:\\ssd-data\\work\\exercises", cradleOptsProg = CradleAction: Stack}
2020-03-16 16:34:10.956753 [ThreadId 3] - New cradle: D:\ssd-data\work\exercises\src\Exercises.hs
2020-03-16 16:34:10.9577531 [ThreadId 3] - Found "D:\ssd-data\work\exercises\hie.yaml" for "D:\ssd-data\work\exercises\src\Exercises.hs"
2020-03-16 16:34:10.9587532 [ThreadId 3] - Module "D:\ssd-data\work\exercises\src\Exercises.hs" is loaded by Cradle: Cradle {cradleRootDir = "D:\\ssd-data\\work\\exercises", cradleOptsProg = CradleAction: Stack}
2020-03-16 16:34:10.9587532 [ThreadId 3] - Found cradle: Cradle {cradleRootDir = "D:\\ssd-data\\work\\exercises", cradleOptsProg = CradleAction: Stack}
hie: Cannot decode byte '\xad': Data.Text.Internal.Encoding.streamDecodeUtf8With: Invalid UTF-8 stream

@fendor
Copy link
Collaborator

fendor commented Mar 16, 2020

The hie.yaml is correct, hie trips over some windows issue. @jneira I think you have encountered this issue before?

@jneira
Copy link
Member

jneira commented Mar 16, 2020

The Cannot decode byte '\xad' part seems to be some encoding issue, similar to this one in ghcide: https://github.com/digital-asset/ghcide/issues/321. So maybe hie-bios could be involved.
Maybe set the encoding in console to utf8, with chcp 65001 could help.

@kirillFedorov1
Copy link

@jneira should I just put chcp 65001 into the terminal and then restart hie? That didn't work :(
I don't quite understand why this problem appeared only after making custom hie.yaml for my project.

@jneira
Copy link
Member

jneira commented Mar 17, 2020

No, sorry for not being precise, i wanted to mean that chcp 65001 could change the behaviour running hie --debug in the console. Do you get the same error (Cannot decode byte '\xad' ) in the hie log or only in the console?

@kirillFedorov1
Copy link

@jneira Yes, the same error appears in the hie log and in the console. chcp 65001 helps to get rid of it, but then I get

hie: hie: panic! (the 'impossible' happened)
  (GHC version 8.6.5 for x86_64-unknown-mingw32):
        can't decompose ghc.exe path: "C:\\Users\\user\\AppData\\Roaming\\local\\bin\\hie.exe"

@jneira
Copy link
Member

jneira commented Mar 17, 2020

@kirillFedorov1 So with chcp 65001 we get ride of the encoding problem in the console, but then we are hitting the original error shown in the hie.log: #1564 (comment)
I think we can concentrate in
can't decompose ghc.exe path: "C:\\Users\\user\\AppData\\Roaming\\local\\bin\\hie.exe"

I guess user is not the real machine user 😉 so at least, could you tell if the user name has non-ascii or spaces in the name (or other interesting attribute)?

@kirillFedorov1
Copy link

@jneira "user" is the real name

@jneira
Copy link
Member

jneira commented Mar 19, 2020

It seems the error is thrown in ghc: https://github.com/ghc/ghc/blob/92b6a0237e0195cee4773de4b237951addd659d9/compiler/main/SysTools/BaseDir.hs#L153-L157

@heathweiss
Copy link

If it helps:
I use stack, but let the .cabal file get generated automatically as I only use package.yaml and stack.yaml. So I delete the .cabal file, rebuild so that cabal is re-generated, than then my test file works.

@jneira jneira changed the title Could not obtain flags for test files Could not obtain flags for test files with cabal-helper cradle using stack May 15, 2020
@jneira
Copy link
Member

jneira commented May 18, 2020

A workaround for this issue, without an explicit hie.yaml is to add:

test: true

to stack.yaml
This way stack will build the tests components and hie will be able to see them.

@mduerig
Copy link

mduerig commented May 30, 2020

And what is the workaround here? I'm a bit lost on all those comments.

@jneira
Copy link
Member

jneira commented May 30, 2020

And what is the workaround here? I'm a bit lost on all those comments.

Yeah, you are right, the possible workarounds are:

  • run stack build --test --no-run-tests each time you have to build the project before opening it in the editor
  • add test: true in the stack.yaml: this is like append --test automatically for all stack comands and run at least one stack build before opening the project

@mduerig
Copy link

mduerig commented May 31, 2020

Thans @jneira . I couldn't get this resolved by those steps though. Unfortunately I tried upgrading stack, which now left me with a completely unworkable setup. See #1782 :(

@freeman42x
Copy link

I am also getting these errors with a cabal project:

/home/neo/Projects/haskell-editor-setup/src/OS/Linux/NixOS.hs: FAILED
        Fail on initialisation for "/home/neo/Projects/haskell-editor-setup/src/OS/Linux/NixOS.hs". Could not obtain flags for: "src/OS/Linux/NixOS.hs".
/home/neo/Projects/haskell-editor-setup/src/OS/Linux/Debian.hs: FAILED
        Fail on initialisation for "/home/neo/Projects/haskell-editor-setup/src/OS/Linux/Debian.hs". Could not obtain flags for: "src/OS/Linux/Debian.hs".
/home/neo/Projects/haskell-editor-setup/src/OS/Prerequisites.hs: FAILED
        Fail on initialisation for "/home/neo/Projects/haskell-editor-setup/src/OS/Prerequisites.hs". Could not obtain flags for: "src/OS/Prerequisites.hs".
/home/neo/Projects/haskell-editor-setup/src/Types.hs: FAILED
        Fail on initialisation for "/home/neo/Projects/haskell-editor-setup/src/Types.hs". Could not obtain flags for: "src/Types.hs".
/home/neo/Projects/haskell-editor-setup/src/Util.hs: FAILED
        Fail on initialisation for "/home/neo/Projects/haskell-editor-setup/src/Util.hs". Could not obtain flags for: "src/Util.hs".
/home/neo/Projects/haskell-editor-setup/src/Main.hs: OK

This is the project/commit for which I am getting the errors: https://github.com/fairy-tale-agi-solutions/haskell-editor-setup/tree/d6c890b33f8dd7bec4cae07e9236a923fb5bd42c

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests