achalk
achalk

Reputation: 3459

Stack: 'hdevtools is a library dependency, but the package provides no library needed since my-app is a build target.'

I was trying to add hdevtools to my stack project, so I ran stack build hdevtools. The install seemed to work successfully, and my text editor stopped reporting imported libraries installed via stack (like aeson and tasty) as missing.

However, things went wrong when I added this line to the dependencies section of my package.yaml file:

- hdevtools >= 0.1 && < 1

And then tried to run stack build again. I received the following error output:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for my-app-name-0.1.0.0:
    hdevtools is a library dependency, but the package provides no library
needed since my-app-name is a build target.

Some different approaches to resolving this:

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt
    to find some working build configuration. This can be convenient when dealing
    with many complicated constraint errors, but results may be unpredictable.


Plan construction failed.

I tried running stack solver, but that threw the exception documented here.

How can I declare hdevtools as a dependency of my project?

Upvotes: 2

Views: 652

Answers (2)

bergey
bergey

Reputation: 3081

@alexis-king recommends using stack build --copy-compiler-tool hdevtools in this guide, in the section titled Setting up editor integration.

This works for the current project, and other projects using the same GHC version, but you will need to run it again when you upgrade to a new GHC version.

More context from King's guide:

As mentioned above, stack install is not what you want. Tools like ghc-mod, hlint, hoogle, weeder, and intero work best when installed as part of the sandbox, not globally, since that ensures they will match the current GHC version your project is using.

Upvotes: 3

Sibi
Sibi

Reputation: 48766

How can I declare hdevtools as a dependency of my project?

hdevtool is an executable and cabal doesn't have a concept of development dependencies (like in other package managers like npm etc). So, all you can do is install hdevtools globally and make it work.

Upvotes: 1

Related Questions