-
Notifications
You must be signed in to change notification settings - Fork 200
Troubleshooting
This page helps you to solve a few common issues with IHP. Longterm we should find solutions for these issues, so that they don't appear every again. Until then, we have this page so that you can find a solution when you paste the error message into Google.
In case your problem cannot be solved with the steps on this page, join our awesome gitter community. We're happy to help!
Run this to automatically check for the most common IHP issues:
curl https://raw.githubusercontent.com/digitallyinduced/ihp/master/Troubleshoot/ihp-troubleshoot | bash
It will tell you what is wrong and the steps you need to do to fix it.
Problem:
Somehow the project was not correctly linked with IHP and now the project Makefile is unable to access some IHP files it needs.
Solution:
Run this command to fix the missing link:
nix-shell --run 'make build/ihp-lib'
If this is not working: Please run which RunDevServer
. If this returns RunDevServer not found
, this indicates that direnv
(which has been installed by ihp-new
) is not loading the .envrc
file of the
To solve this, run the following commands:
Bash Users
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
ZSH Users (default on macOS)
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
Other shells: take a look at the direnv documentation.
After that restart your terminal. Then run the following command again to fix the missing link:
nix-shell --run 'make build/ihp-lib'
Now this should succeed.
Problem:
When you try to start a new ihp project by running ihp-new someproject
, nix seems to start compiling a lot of haskell packages with ghc.
Solution:
This is most likely caused by a change we did to our binary cache. Run cachix use digitallyinduced
to fix this.
warning: substituter 'https://digitallyinduced.cachix.org' does not have a valid signature for path ...
Problem:
When running ihp-new someproject
to create a new project, nix seems to not use the binary cache with the above warning. Instead it tries to build all the packages itself, which takes hours.
Solution:
This is caused by a change we did to our binary cache. Open ~/.config/nix/nix.conf
. There take a look at the trusted-public-keys =
property. You should have two entries there (the public key of our old binary cache, and the new one). Remove the old one digitallyinduced.cachix.org-1:3mGU1b6u5obFp2VUfI55Xe8/+mawl7y9Eztu3rb94PI=
(should be first of the two digitallyinduced keys). Then save the file and the problem is fixed.
Problem:
When you try to start a nix-shell
, an error like this happens:
$ ./start
error: file '/build/db/.s.PGSQL.5432' has an unsupported type
Solution:
This happens because nix cannot deal the postgres unix socket which is in build/db
. Usually this happens when the dev server of IHP is still running. Stop your IHP dev server and then try again.
When the dev server is not running, check that you have no postgres processes belonging to this unix socket running anymore. In case there are no processes running anymore, try to remove the file via rm -f
.
Full error message looks like this:
MyModule.hs:7:29: error:
* Unbound implicit parameter (?modelContext::ModelContext)
arising from a use of `fetch'
* In the second argument of `(|>)', namely `fetch'
In a stmt of a 'do' block: users <- query @User |> fetch
In the expression:
do users <- query @User |> fetch
return users
|
7 | users <- query @User |> fetch
Problem:
IHP uses an implicit parameter called ?modelContext
to pass around the database connection. The ?
question mark is part of the variable name. When you do a database query from a helper function outside of your controller actions the database connection needs to be passed to your function. This works automatically because it's an implicit parameter but needs to be specified inside your type signature.
Solution:
Add (?modelContext :: ModelContext) =>
to the start of your type signature.
-- OLD:
fetchUser :: Text -> IO [User]
fetchUser name = do
users <- query @User |> fetch
return users
-- NEW:
fetchUser :: (?modelContext :: ModelContext) => Text -> IO [User]
fetchUser name = do
users <- query @User |> fetch
return users