I am trying to learn how to use stack to build Haskell project. I run from a command line:
stack new helloworld new-template
cd helloworld
stack build
I get
Error parsing targets: The specified targets matched no packages.
Perhaps you need to run 'stack init'?
Any idea? I am on Windows.
Try to upgrade your stack version with stack upgrade, you might be using some outdated or unstable version.
Related
Is there a way to specify which executable to run (with stack run) when I am working with a Stack multi package project?
My problem was that I was using the package name rather than the executable name in my stack run command:
Wrong: stack run foo
Correct: stack run foo-exe
I am currently trying to install stack to utilise the software Taiji. I have been able to run 'stack setup', but get an error when I run stack install:
C:\Users\My Name\Taiji-1.2.1>stack install
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for shelly-1.8.1:
unix needed, but the stack configuration has no specified version (latest matching version is 2.7.2.2)
needed due to Taiji-1.2.1 -> shelly-1.8.1
Some different approaches to resolving this:
* Recommended action: try adding the following to your extra-deps in C:\Users\My Name\Taiji-1.2.1\stack.yaml:
- unix-2.7.2.2#sha256:9e93f93cc5a065248120136e83a0a6d1ce93d6eb5ef2a2543f9593e93e164d24,3496
Plan construction failed.
I am guessing I'll have to install another package of some sort and put it into the Taiji-1.2.1 folder, but am not exactly sure how(I am completely new to stack/programming). Is anyone able to help me with this issue? Thanks kindly.
When you see this error, you will need to open stack.yaml (the error message contains the full path), find the line saying # extra-deps: [], and replace it with the line shown in the error message:
extra-deps:
- unix-2.7.2.2#sha256:9e93f93cc5a065248120136e83a0a6d1ce93d6eb5ef2a2543f9593e93e164d24,3496
(If you already have something listed in extra-deps, then you can just add that line to the end of extra-deps rather than replacing the whole thing.)
Now, this is usually enough. But you’ve got a further problem: you are using Windows, but you’re trying to compile a program which depends on the unix package — a package which is not available on Windows. Due to this, you will not be able to compile your program on Windows.
(As for why all that extra-deps stuff is needed: basically, Stack maintains a list of package versions known to work with each other, but occasionally you will run into a package which isn’t in that list. In that case you will need to list that package version in extra-deps to tell Stack which version to use.)
In my Haskell project when I stack run, it is showing the following, but still runs. What warning is this? How can I get rid of it?
Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
This is just a compatibility warning. The next stack version should be tested with GHC 8.8 and this warning should be gone. Until then there's probably little you can do unless you want to modify the source.
As the others said, this can be most likely be ignored. If you want to be on the super-safe side, edit your stack.yaml and downgrade the resolver back to 14.x (latest at this point is 14.27).
You can specify a resolver when creating a project to get rid of this warning:
stack new hello-world simple --resolver=lts-14.27
This may cause other warnings you actually care about to be suppressed, but if you run stack --verbosity error or stack --silent you won't see these warnings. For example
stack --verbosity error exec <your program>
I am trying to get wx installed using stack. I don't have Haskell installed globally and use stack new <app> new-template to create a new project. Next, within the directory I run stack install wx and get an error message:
In the dependencies for wx-0.92.3.0:
wxcore must match >=0.92, but the stack configuration has no specified
version (latest matching version is 0.92.3.0)
Following-up the recommended actions and rerunning stack install wx a couple of times, the extra-deps list looks like this:
- wxcore-0.92.3.0
- wxc-0.92.3.0
- wxdirect-0.92.3.0
- Cabal-1.24.2.0
- process-1.4.3.0
- base-4.10.1.0
at this point, stack complains:
In the dependencies for process-1.4.3.0:
base-4.11.1.0 from stack configuration does not match >=4.4 && <4.11
(latest matching version is 4.10.1.0)
and suggesting to add base-4.10.1.0 again, but which is already there.
Q: so, how should I install wx?
Is it really that hard to get wxHaskell going? Should I start using cabal instead of stack?
I use the latest stack version 1.7.1 with lts-12.4 as the resolver.
A similar question was posted back in 2015.
The hint given by Stéphane Laurent works! On my Debian 9 (stretch) I used the following steps:
Install the required libraries
sudo apt-get install libwxgtk3.0-dev libwxgtk-webview3.0-dev libwxgtk-media3.0-dev
Create a stack project with stack new <app> new-template and change to the <app> directory
Make the following changes to the stack.yaml file:
resolver: lts-8.16
extra-deps:
- wxdirect-0.92.3.0
- wxc-0.92.3.0
- wxcore-0.92.3.0
- wx-0.92.3.0
Run stack install wx and be patient!
Add - wx to the list of dependencies in the package.yaml file
I'm new to yesod and just trying to use stack to build one or two basic sites from the templates but I get an Aeson error when I do. There is a discussion of the error message here [0] but it is apparently fixed in 1.6.1 and I'm using 1.6.3. This is what I'm trying:
$ stack --version
Version 1.6.3
$ stack new yesod-project yesod-sqlite
Downloading template "yesod-sqlite" to create project "yesod-project" in yesod-project/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- yesod-project/
Selecting the best among 12 snapshots...
* Matches lts-10.5
Selected resolver: lts-10.5
Initialising configuration using resolver: lts-10.5
Total number of user packages considered: 1
Writing configuration to file: yesod-project/stack.yaml
All done.
$ cd yesod-project/
$ stack build
$ stack exec -- yesod devel
Yesod devel server. Enter 'quit' or hit Ctrl-C to quit.
Application can be accessed at:
http://localhost:3000
https://localhost:3443
If you wish to test https capabilities, you should set the following variable:
export APPROOT=https://localhost:3443
Downloading lts-10.5 build plan ...
Downloaded lts-10.5 build plan.
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""
Type help for available commands. Press enter to force a rebuild.
[0] https://github.com/commercialhaskell/stack/issues/3634
If you run stack exec -- stack --version I bet you will find that it is older than 1.6.3. You should probably delete the stack binary at stack exec -- which stack
mgsloan's assessment of the cause is correct, at least in my case.
Solution-wise, I'm guessing deleting the stack binary forces it to upgrade. For those who are hesitant to delete stack, stack upgrade did the trick for me.