skip to Main Content

I am trying to learn Yesod and I started to have a look at https://www.yesodweb.com/book.

Before reading the book, I executed on my WSL2 Ubuntu 20.04 LTS the instructions provided at https://www.yesodweb.com/page/quickstart :

curl -sSL https://get.haskellstack.org/ | sh
stack new yesod-book yesodweb/sqlite && cd yesod-book
stack install yesod-bin --install-ghc # install yesod cli
# updated the $PATH in my .zshrc and reloaded the terminal
stack build
stack test --flag yesod-book:library-only --flag yesod-book:dev

Compilation works with some warnings at /mnt/d/Code/yesod_and_haskell/src/Model.hs:23:1: warning: [-Wname-shadowing] but this does not prevent the examples to succeed.

However, when I run the development server

stack exec -- yesod devel
# ...
[12 of 12] Compiling Paths_yesod_book
yesod-book> copy/register
Installing library in /mnt/d/Code/yesod_and_haskell/.stack-work/install/x86_64-linux/f0163dccc19ddaa0efa9ec567b016ae57bd5477fab521d675f34f49ffd7923d3/9.2.7/lib/x86_64-linux-ghc-9.2.7/yesod-book-0.0.0-11M4iC3bTuY3cNtaxd5kQS
Registering library for yesod-book-0.0.0..
Success! Waiting for next file change.
Type help for available commands. Press enter to force a rebuild.

When I connect to http://localhost:3000 I keep seeing

enter image description here

I tried to clear all the hidden folders containing build artifacts and rebuilding the project from scratch but this did not help.

stack --version
Version 2.9.1, Git revision 409d56031b4240221d656db09b2ba476fe6bb5b1 x86_64 hpack-0.35.0
yesod version  
yesod-bin version: 1.6.2.2
ghci version
GHCi, version 9.2.5

I am looking at past issues on github, but I am not sure about how to make them actionable for my problem:

The full configuration of my sample project can be found at this repo

How can I run my default application in devel mode?

2

Answers


  1. Chosen as BEST ANSWER

    Following @schoettl comment and yesodweb/yesod/issues#1755, I tried to run the application from gchi instead of yesod bin.

    $ stack ghci yesod-book:lib --no-load --work-dir .stack-work-devel
    ghci> :l app/DevelMain.hs
    ghci> DevelMain.update
    

    This shown the logs described by @sergiu-starciuc comments

    Migrating: CREATE TABLE "user"("id" INTEGER PRIMARY KEY,"ident" VARCHAR NOT NULL,"password" VARCHAR NULL,CONSTRAINT "unique_user" UNIQUE ("ident"))
    Migrating: CREATE TABLE "email"("id" INTEGER PRIMARY KEY,"email" VARCHAR NOT NULL,"user_id" INTEGER NULL REFERENCES "user" ON DELETE RESTRICT ON UPDATE RESTRICT,"verkey" VARCHAR NULL,CONSTRAINT "unique_email" UNIQUE ("email"))
    Migrating: CREATE TABLE "comment"("id" INTEGER PRIMARY KEY,"message" VARCHAR NOT NULL,"user_id" INTEGER NULL REFERENCES "user" ON DELETE RESTRICT ON UPDATE RESTRICT)
    Devel application launched: http://localhost:3000
    ghci> 127.0.0.1 - - [11/Apr/2023:23:12:51 +0200] "GET / HTTP/1.1" 200 - "" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
    

    And the application worked as expected.


  2. Try cleaning before building and running:

    yesod-book$ stack clean && stack build && stack exec -- yesod devel

    Also make sure you have the required System libraries installed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search