IHP 1.1 is out now!

Compile error on 'StaticControllerinstance'

hansw

Hi,

I'm following the First App tutorial and I'm running into this error when creating a controller named 'Posts'.

What could have gone wrong? And how can I get going again?

To reproduce:

  • sudo ihp-new blog
  • sudo chown -R user:users blog/
  • cd blog
  • ./start
  • Create DB model and press 'Update DB';
  • Enter Code-gen; add controller 'Posts', preview; -- up to here all goes well
  • press 'Generate' and the compile window gives compile errors.
[ 5 of 19] Compiling Web.Types        ( Web/Types.hs, interpreted )
[ 6 of 19] Compiling Web.Routes       ( Web/Routes.hs, interpreted )

Web/Routes.hs:7:20: error:
    Not in scope: type constructor or class ‘StaticControllerinstance’
  |
7 | instance AutoRoute StaticControllerinstance AutoRoute PostsController
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^
[ 7 of 19] Compiling Web.Controller.Prelude ( Web/Controller/Prelude.hs, interpreted ) [Web.Types changed]
Failed, six modules loaded.

I'm running on Nixos.

Here's the output of ihp-troubleshoot:

$ bash ihp-troubleshoot
Checking that the current directory is an IHP project:
+ Found Main.hs
+ Found start
Checking nix:
+ Nix installed
Checking direnv:
+ Found .envrc
+ direnv loads .envrc
+ ghci is loaded from nix store
Checking .ghci:
+ Found .ghci
+ .ghci permissions are ok
Checking IHP:
+ Symlink build/ihp-lib exists
+ Symlink build/ihp-lib target exists
+ IHP used from nix
Checking Cachix:
- Cachix config is missing. Is cachix installed?
cat: /home/user/.config/nix/nix.conf: No such file or directory
- digitallyinduced.cachix.org binary cache missing. Try 'cachix use digitallyinduced'
cat: /home/user/.config/nix/nix.conf: No such file or directory
+ No legacy cachix key found
Debugging Details:
GHCI Output:
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from /home/user/ihp/blog2/.ghci
IHP> ok
IHP> Leaving GHCi.
build/ihp-lib Target:
/nix/store/gdlksfh4afv3dk8wkcmwsn670rf5kjkl-ghc-8.8.3-with-packages/lib/IHP
Direnv Output:
direnv exec path /nix/store/c6sh3476va60wqck3iam87vbj93k34rg-direnv-2.21.2-bin/bin/dir\
env
DIRENV_CONFIG /home/user/.config/direnv
bash_path /nix/store/xadrr3l5jvkkm3g3lb2g81j5wz51zqdv-bash-interactive-4.4-p23/bin/bas\
h
disable_stdin false
warn_timeout 5s
whitelist.prefix []
whitelist.exact map[]
Loaded RC path /home/user/ihp/blog2/.envrc
Loaded watch: ".envrc" - 2020-10-31T16:46:21+01:00
Loaded watch: "../../.local/share/direnv/allow/dc29e63ea60b0ec67c0788bfb8089bf6f3a8f3c\
b69b08b9f7ed4427f70bc67fa" - 2020-10-31T16:46:21+01:00
Loaded RC allowed false
Loaded RC allowPath
Found RC path /home/user/ihp/blog2/.envrc
Found watch: ".envrc" - 2020-10-31T16:46:21+01:00
Found watch: "../../.local/share/direnv/allow/dc29e63ea60b0ec67c0788bfb8089bf6f3a8f3cb\
69b08b9f7ed4427f70bc67fa" - 2020-10-31T16:46:21+01:00
Found RC allowed true
Found RC allowPath /home/user/.local/share/direnv/allow/dc29e63ea60b0ec67c0788bfb8089b\
f6f3a8f3cb69b08b9f7ed4427f70bc67fa
which direnv Output:
/nix/store/gdlksfh4afv3dk8wkcmwsn670rf5kjkl-ghc-8.8.3-with-packages/bin/ghci
default.nix:
let
    ihp = builtins.fetchGit {
        url = "https://github.com/digitallyinduced/ihp.git";
        rev = "a8030dd1e4041a0353f63d03b4ffb836cb2bd95c";
    };
OS:
Linux
jakosimov

Hey,

I got the same error when I tried to follow the tutorial. It happened because a fault in the code generation. Your Routes.hs file is supposed to contain something like this

instance AutoRoute StaticController
instance AutoRoute PostsController

but that was instead generated as

instance AutoRoute StaticControllerinstance AutoRoute PostsController

To fix it you can manually add the newline to the Routes.hs file with a text editor.

marc PRO

Thanks for reporting. There's been a lot of reports of this problem, so I just pushed out a new release with a fixed code generator. You can find it here: https://github.com/digitallyinduced/ihp/releases/tag/v20201101