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

Problems with Suave 2.2.0 and Liquid #642

Closed
mrkaspa opened this issue Aug 17, 2017 · 32 comments
Closed

Problems with Suave 2.2.0 and Liquid #642

mrkaspa opened this issue Aug 17, 2017 · 32 comments

Comments

@mrkaspa
Copy link

mrkaspa commented Aug 17, 2017

I made a simple example and got this error

open DotLiquid
open Suave
open Suave.Filters
open Suave.Operators
open Suave.Successful
open Suave.DotLiquid

type Model =
  { title : string }

setTemplatesDir "./../templates"

let o = { title = "Hello World" }

let app =
  choose
    [ GET >=> choose
        [ path "/" >=> page "my_page.liquid" o ]]

startWebServer defaultConfig app
Unhandled Exception: System.TypeInitializationException: The type initializer for 'Suave.DotLiquid' threw an exception. ---> System.TypeInitializationException: The type initializer for '<StartupCode$Suave-DotLiquid>.$Suave.DotLiquid' threw an exception. ---> System.MissingFieldException: Field not found: 'DotLiquid.Template.NamingConvention'.
   --- End of inner exception stack trace ---
   at Suave.DotLiquid..cctor()
   --- End of inner exception stack trace ---
   at Suave.DotLiquid.setTemplatesDir(String dir)
   at <StartupCode$GitRankFs>.$Program.main@() in /Users/mrkaspa/code/GitRankFs/Program.fs:line 12
@haf
Copy link
Contributor

haf commented Aug 17, 2017

DotLiquid v2.0.55? https://www.nuget.org/packages/Suave.DotLiquid/

Could you submit a PR to bump DotLiquid please?

@mrkaspa
Copy link
Author

mrkaspa commented Aug 17, 2017

@haf with that dependency got this error when tries to render

[09:04:54 INF] Smooth! Suave listener started in 73.903 with binding 127.0.0.1:8080
[09:04:58 ERR] request failed
System.TypeLoadException: Could not load type 'Async' from assembly 'Suave, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null'.
   at Suave.DotLiquid.renderPageFile[m](String fileFullPath, m model)
   at Suave.DotLiquid.page@183.Invoke(Unit unitVar)
   at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@839.Invoke(AsyncParams`1 args)

@haf
Copy link
Contributor

haf commented Aug 17, 2017

Runtime?

@mrkaspa
Copy link
Author

mrkaspa commented Aug 17, 2017

dotnet core 2

@haf
Copy link
Contributor

haf commented Aug 17, 2017

It's supposed to bind to module [<AutoOpen>] Suave.Utils.YoLo which contains Async.map, which is failing for you. (And because of open Suave.Utils at the top of DotLiquid/Library.fs). Binding should work, because this exists:

screen shot 2017-08-17 at 16 17 26

And because it all compiles on both mono and .net core. I did build it using .Net core of a previous version though.

@haf
Copy link
Contributor

haf commented Aug 17, 2017

$ dotnet --version
1.0.4

For me.

@haf
Copy link
Contributor

haf commented Aug 17, 2017

I'd update, but there are no command line instructions at https://www.microsoft.com/net/core#macos

@haf
Copy link
Contributor

haf commented Aug 17, 2017

PIng @enricosada – what would be my next steps?

@haf
Copy link
Contributor

haf commented Aug 17, 2017

Also ping @ademar – are we moving to .Net core 2.0?

@haf
Copy link
Contributor

haf commented Aug 17, 2017

@mrkaspa If you could PR that bump of DotLiquid meanwhile, I could get that merged.

@mrkaspa
Copy link
Author

mrkaspa commented Aug 17, 2017

@haf what do you mean? should I create the issue in DotLiquid?

@haf
Copy link
Contributor

haf commented Aug 17, 2017

No, I'm thinking you could bump the version of DotLiquid in this repo and send that as a PR. That way the CI infrastructure can test it out.

@haf
Copy link
Contributor

haf commented Aug 17, 2017

Related #639 #637 #609

@jimfoye
Copy link
Contributor

jimfoye commented Aug 17, 2017

That TypeInitializationException is exactly what I was seeing in #641.

@mrkaspa
Copy link
Author

mrkaspa commented Aug 20, 2017

is there a solution for this? may be another template system?

@haf
Copy link
Contributor

haf commented Aug 20, 2017

@mrkaspa Could you try the new release v2.2.1 where I bumped the dependency, to start with?

@haf
Copy link
Contributor

haf commented Aug 20, 2017

Besides that, I'm having trouble building Suave with .Net Core 2.0, so I can't try recompiling it right now.

@mrkaspa
Copy link
Author

mrkaspa commented Aug 20, 2017

@haf got problems with that version too

@haf
Copy link
Contributor

haf commented Aug 20, 2017

@mrkaspa I see. Thanks for letting us know.

Yes, there are other backends, like Razor, Suave.Experimental and the one that is currently a PR since yesterday (see PR #644)

Of course it would be optimal to sort this issue out; if you'd feel up for digging about the internals of cross-platform cross-runtime builds, so I don't have to ;)

@mrkaspa
Copy link
Author

mrkaspa commented Aug 20, 2017

@haf honestly I'm a f# beginner learning the language and wanted to build a small experiment web site, so I can't be much help

@haf
Copy link
Contributor

haf commented Aug 20, 2017

Of course. Then I'd recommend https://www.gitbook.com/book/theimowski/suave-music-store/details which uses the F# view engine.

@ademar
Copy link
Member

ademar commented Aug 20, 2017

Also ping @ademar – are we moving to .Net core 2.0?

I'll leave that decision to you. I am still running my stuff in old .NET/Mono

@mrkaspa
Copy link
Author

mrkaspa commented Aug 21, 2017

@haf the guide is too outdated it uses Suave 1

@mrkaspa
Copy link
Author

mrkaspa commented Aug 21, 2017

@haf this works with on the 2.0.4 version but from 2.0.5 starts breaking with this error

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Suave, Version=2.0.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

@haf
Copy link
Contributor

haf commented Aug 21, 2017

@mrkaspa I think the view engine docs of that guide are pretty much up to date.

You last message doesn't contain enough information to debug.

I suggest you start with mono and await someone who works with .Net Core to come by and help out with these loader errors.

@matthid
Copy link
Contributor

matthid commented Aug 21, 2017

The Could not load file or assembly 'Suave ... is probably #635
I'm unsure about the initial reported errors...

@manio143
Copy link

I'm running on Mono and saw the same issues with Suave.DotLiquid, throwing the initializer exception. However, when I dropped the nuget package and simply included Suave.DotLiquid/Library.fs into my project it works fine with DotLiquid 2.0.168
So the problem is probably with the Suave.DotLiquid package rather then the source code.
But I have no idea what might the problem be.

@jimfoye
Copy link
Contributor

jimfoye commented Aug 22, 2017

From the readme.txt for DotLiquid:

INamingConvention have now a new member: `bool OperatorEquals...

Almost certainly this is the culprit.

@inosik
Copy link
Contributor

inosik commented Aug 23, 2017

The reason for this is that somewhere between DotLiquid 2.0.55 and 2.0.168, DotLiquid.Template.NamingConvention changed from being a public static field to a public static property, which is a breaking change for compiled assemblies.

Although the DotLiquid package is referenced from Pakets Main group in Suave.DotLiquid, the net40 assembly gets compiled against 2.0.64:

.assembly extern DotLiquid
{
  .publickeytoken = (82 E4 60 16 EC F9 F0 7C )                         // ..`....|
  .ver 2:0:64:0
}

And the netstandard1.6 one against 2.0.55:

.assembly extern DotLiquid
{
  .publickeytoken = (82 E4 60 16 EC F9 F0 7C )                         // ..`....|
  .ver 2:0:55:0
}

The .NET Standard project references 2.0.55, but the .NET Framework project should reference 2.0.158. I think there is some MSBuild reference resolution magic going on here, which spits 2.0.64 into the mix. 2.0.64 is resolved in the "Tests" dependency group.

So I think the DotLiquid package needs to be updated everywhere: in every Paket group and in the Suave.DotLiquid.netcore project.

@inosik
Copy link
Contributor

inosik commented Aug 23, 2017

Using Pakets strategy: min option could also fix this.

@haf
Copy link
Contributor

haf commented Aug 23, 2017

If you have a working environment; it would be great if you could PR some of that.

@inosik
Copy link
Contributor

inosik commented Aug 23, 2017

Unfortunately, I don't. I just looked into the assemblies with ILDasm.

@haf haf closed this as completed Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants