Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: type mismatch Expression: httpbeast.initSettings #329

Open
ejstembler opened this issue Mar 31, 2024 · 5 comments
Open

Error: type mismatch Expression: httpbeast.initSettings #329

ejstembler opened this issue Mar 31, 2024 · 5 comments

Comments

@ejstembler
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

ejstembler commented Apr 4, 2024

@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-4834f85e61ae39f6b6acfb74d3bbba62d8779b66nimble 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-b23e57a401057dcb9b7fae1fb8279a6a2ce1d0b8nimble install jester

Downloading https://github.com/dom96/jester using git
  Verifying dependencies for [email protected]
 Installing httpbeast@>= 0.4.0
Downloading https://github.com/dom96/httpbeast using git
  Verifying dependencies for [email protected]
     Info:  Dependency on asynctools@#0e6bdc3ed5bae8c7cc9 already satisfied
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  httpbeast installed successfully.
 Installing [email protected]
  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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants