dom96 / jester

A sinatra-like web framework for Nim.
MIT License
1.56k stars 120 forks source link

Error: type mismatch Expression: httpbeast.initSettings #329

Open ejstembler opened 3 months ago

ejstembler commented 3 months ago

Does the Custom router code on the README still work?

import asyncdispatch, jester, os, strutils

router myrouter:
  get "/":
    resp "It's alive!"

proc main() =
  let port = Port(parseInt(getEnv("PORT")))
  let settings = newSettings(port=port)
  var jester = initJester(myrouter, settings=settings)
  jester.serve()

when isMainModule:
  main()
dotenv -o -f ".env" nim c -o:bin/app -r src/app.nim

Returns this compliation error:

~/.nimble/pkgs2/jester-0.6.0-4834f85e61ae39f6b6acfb74d3bbba62d8779b66/jester.nim(531, 29) Error: type mismatch
Expression: httpbeast.initSettings(self.settings.port, self.settings.bindAddr,
                       self.settings.numThreads)
  [1] self.settings.port: Port
  [2] self.settings.bindAddr: string
  [3] self.settings.numThreads: int

Expected one of (first mismatch at [position]):
[3] proc initSettings(port: Port = Port(8080); bindAddr: string = ""): Settings
ThomasTJdev commented 3 months ago

Hi @ejstembler

The example works fine for me with jester == 0.6.0 and httpbeast == 0.4.1/0.4.2. It looks like you are compiling against an old httpbeast version.

1) What's your Nim compiler? 2) What's your httpbeast version?

ejstembler commented 3 months ago
nimble list -i

asynctools  [(version: 0.1.1, checksum: 54314dceabb06b20908ecb0f2c007e9ff3aaa054)]
db_connector  [(version: 0.1.0, checksum: f9aa61913b739de65d6106323d270639016a54ba)]
httpbeast  [(version: 0.4.1, checksum: b23e57a401057dcb9b7fae1fb8279a6a2ce1d0b8)]
jester  [(version: 0.6.0, checksum: 4834f85e61ae39f6b6acfb74d3bbba62d8779b66)]
mustache  [(version: 0.4.3, checksum: 9c7e49440ae9bb6494bd202eea6ef7405811c6bb)]
nim -v

Nim Compiler Version 2.0.2 [MacOSX: amd64]
Compiled at 2024-03-31
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release
ThomasTJdev commented 3 months ago

Please try to compile with --forceBuild:on and in the compile log find the folder reference to httpbeast and ensure, that it's actually pointing to your httpbeast == 0.4.1 folder. I have the same httpbeast with checksum b23e57a401057dcb9b7fae1fb8279a6a2ce1d0b8 and that includes the full initSettings() proc.


Jester + Httpbeast on Nim v2.0 You are running Jester with Nim v2.0. There's a known problem with Httpbeast, since dom96 has not created new tags for it. I'm using this fork: https://github.com/ThomasTJdev/jester_fork which uses this fork: https://github.com/ThomasTJdev/httpbeast_fork. Please see:

ejstembler commented 3 months ago

@ThomasTJdev I tried removing jester and httpbeast, then re-installing jester. However, the error persists.

➜ nimble remove jester  

    Looking for jester (any version)
   Checking reverse dependencies
    Prompt: The following packages will be removed:
        ... jester-0.6.0-4834f85e61ae39f6b6acfb74d3bbba62d8779b66
        ... Do you wish to continue? [y/N]
    Answer: y
    Removed jester-0.6.0-4834f85e61ae39f6b6acfb74d3bbba62d8779b66

➜ nimble remove httpbeast

    Looking for httpbeast (any version)
   Checking reverse dependencies
    Prompt: The following packages will be removed:
        ... httpbeast-0.4.1-b23e57a401057dcb9b7fae1fb8279a6a2ce1d0b8
        ... Do you wish to continue? [y/N]
    Answer: y
    Removed httpbeast-0.4.1-b23e57a401057dcb9b7fae1fb8279a6a2ce1d0b8

➜ nimble install jester

Downloading https://github.com/dom96/jester using git
  Verifying dependencies for jester@0.6.0
 Installing httpbeast@>= 0.4.0
Downloading https://github.com/dom96/httpbeast using git
  Verifying dependencies for httpbeast@0.4.1
     Info:  Dependency on asynctools@#0e6bdc3ed5bae8c7cc9 already satisfied
  Verifying dependencies for asynctools@0.1.1
 Installing httpbeast@0.4.1
  Success:  httpbeast installed successfully.
 Installing jester@0.6.0
  Success:  jester installed successfully.

➜ nim c -f -o:bin/app -r src/app.nim

Hint: used config file '/Users/ejstembler/.choosenim/toolchains/nim-2.0.2/config/nim.cfg' [Conf]
Hint: used config file '/Users/ejstembler/.choosenim/toolchains/nim-2.0.2/config/config.nims' [Conf]
...............................................................................................................................................................................
/Users/ejstembler/.nimble/pkgs2/jester-0.6.0-4834f85e61ae39f6b6acfb74d3bbba62d8779b66/jester.nim(531, 29) Error: type mismatch
Expression: httpbeast.initSettings(self.settings.port, self.settings.bindAddr,
                       self.settings.numThreads)
  [1] self.settings.port: Port
  [2] self.settings.bindAddr: string
  [3] self.settings.numThreads: int

Expected one of (first mismatch at [position]):
[3] proc initSettings(port: Port = Port(8080); bindAddr: string = ""): Settings

Where can I find the compile log? I didn't see any reference of it at Nim Compiler User Guide.

What else should I try?

Thanks.

ThomasTJdev commented 3 months ago

Hi @ejstembler

1) I'm not familiar with Mac - so I can only test on Linux. I don't know whether that could affect it. 2) There has been some trouble for some users when upgrading from Nim v1.6.x to Nim v2.0.x with the nimble-packages. Some users had to delete the .nimble/pkgs* folders. Maybe try using the nimbledeps folder to ensure that it's the correct packages: https://forum.nim-lang.org/t/11293#73882 3) The compile-log is truncated in your message - all the ........... Try to compile with --forceBuild:on and then inspect the the compile outputs directory references to the httpbeast folder, which should be like: CC: ../../.nimble/pkgs/httpbeast-0.4.2/httpbeast.nim

If that's not providing any answers, then you might want to try https://github.com/guzba/mummy with https://github.com/ThomasTJdev/mummy_utils