I'm trying out HAppStack. I installed HAppStack and created a project: happstack new project web
. New folder 'web' created with project guestbook under it. So now I want to run it. The only way I could do it is run cabal install
. But I want to run my app without installing with cabal! Executing run.sh errors: Could not find module 'Paths_guestbook'. How can I do it?
Edit: In general, is there a way to run HAppStack app without rebuild like in Snap?
SHORT VERSION:
The run.sh seems to be missing an include paramater. Modify it to look like this:
I have update the run.sh in darcs to include this change.
LONG VERSION:
Normally that flag is not needed for Happstack applications. You can usually just do,
runhaskell Main.hs
. But in that particular example the Main.hs explicitly imports:which is used in the
versionInfo
function so that the server can report its own version number. Though version number insrc-interactive-only
is hardcoded and will generally be out of date. So it is only correct if you actually build with cabal.The
Paths_guestbook
module is normally created automatically whencabal build
is run. So, another fix would be to change the run.sh to:And run
cabal configure && cabal build
once. After that you will be able to userun.sh
(until you do acabal clean
).Another option would be to set a CPP flag in the .cabal file, and only import
Paths_guestbook
when the application is being built via cabal.For example in the happstack.com source code:
http://patch-tag.com/r/stepcut/happstackDotCom/snapshot/current/content/pretty/Main.hs
In line 40 (or so) you will see an
#ifdef __CABAL__
. happstack.com needs to be able to know where to find the static content such as .css files. When doingrunhaskell Main.hs
in the local directory, it will look for the files in a sub-directory of the local directory. If you docabal install
it will instead look whevercabal
installs the data files. Or, you can override the default location with command-line arguments. (Which is what the debian packaging for that app does).Unfortunately, the
happstack new project
command is somewhat bitrotten because the author became a parent and has not had time to work on it in a long time. It will likely be removed from the upcoming Happstack release in order to reduce confusion.In order to be truly useful, I think the command needs to prompt for a bunch of values and then generate a new project from a set of templates. Similar to how 'cabal init' works. But currently, no one has volunteered the time to make that happen.
To see changes to your source appear automatically with out restarting the server you can use the
happstack-plugins
library. There is an screencast of it here:http://happstack.blogspot.com/2010/10/recompile-your-haskell-based-templates.html