Executable named yesod not found on path - haskell

Getting this issue while trying to run my Yesod application. stack build has already been run and gives no output anymore.
$ stack exec -- yesod devel
Executable named yesod not found on path: ["path/to/app"]

Turns out yeosd-bin needs to be compiled separately.
Running $ stack build yesod-bin solves the issue.

Related

stack run in multi package project

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

Getting started with stack on Windows

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.

ghc.exe: unable to load package <package_name>

I have recently started learning haskell and have never used the cabal package manager before. I'm currently working on a project that requires me to user the io-streams package.
I of course already have the Haskell Platform installed on my machine. I am currently using the x86_64-core version 8.4.3 installer.
Using a Git Bash terminal on Windows 10, I have created a .cabal-sandbox/ folder (using the cabal sandbox init command), in which to house all of my downloaded packages. I have then run cabal install io-streams to download and install the package from the Hackage site. This has worked fine.
I have now come to writing my code. This is as follows:
module StreamFiles where
import System.IO.Streams.File
main:: IO ()
main = do
putStrLn "some text here"
However, when I come to run this, using the following steps:
1. Run the cabal repl command in the directory where the .cabal-sandbox/ folder is located.
2. I then run the following in Powershell:
Prelude> :l src/fileStreaming/streamfile.hs
[1 of 1] Compiling StreamFile ( src\fileStreaming\streamfile.hs, interpreted )
Ok, one module loaded.
*StreamFile> main
And get the following error:
ghc.exe: | C:\Users\UserName\source\repos\complexHaskell\.cabal-sandbox\x86_64-windows-ghc-8.4.3\network-3.0.1.0-HkosMKsQUp05NPIgp4K8kv\HSnetwork-3.0.1.0-HkosMKsQUp05NPIgp4K8kv.o: unknown symbol `if_nametoindex'
ghc.exe: unable to load package `network-3.0.1.0'
And I cannot work out why. Is this a package problem or is there a step that I have missed when pulling the packages down from the Hackage site?
Do I need to create a .cabal file using the cabal init command and require some dependencies for my imports in there??
Thanks in advance.
C.

Use dependencies in Hint when Installing

I'm writing a project using Haskell, stack and hint. I'm using hint to interpret a user-supplied module. The catch is that this module uses types and functions from a dependency. When I run my program using stack exec, everything works fine. However, when I install my program (using stack install --local-bin-path bin) and try to run the executable generated, the GHC interpreter fails with an error: Could not find module <module>. This is because (I think) it can't find the files needed for it to interpret source code referring to this dependency. Does anyone know how to fix this? I'm using Windows 10.
I've uploaded a minimal not-working example at https://github.com/bradrn/stack-overflow-hint-dependencies. It works fine if you do stack exec stack-overflow-hint-dependencies, but if you do stack install --local-bin-path bin it fails with Could not find module 'Data.Finite' when you try to interpret something.

Aeson error building test yesod-sqlite project

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.

Resources