简体   繁体   English

无法在Linux上使用F#Chiron Json序列化程序

[英]Cannot get F# Chiron Json serializer working on Linux

I cannot get Chiron Json serializer working on Elementary OS with VS Code. 我无法让Chiron Json序列化程序在带有VS Code的Elementary OS上运行。

On Windows it works as I tested it. 在Windows上,它可以按照我的测试进行工作。 On MacOS it works as well if I recall correctly. 如果我没记错的话,在MacOS上也可以正常工作。

Here is the minimal not-working solution: 这是最小的无效解决方案:

This is the script file App.fsx : 这是脚本文件App.fsx

#load "paket-files/include-scripts/net46/include.chiron.fsx"

open Chiron

printfn "%A" (Object <| Map.ofList [ "foo", String "bar" ] |> Json.format)

This is the paket.dependencies file: 这是paket.dependencies文件:

source https://www.nuget.org/api/v2
nuget Chiron

Include scripts have to be generated. 包含脚本必须生成。 Either from IDE or by executing mono ./paket/paket.exe generate-include-scripts . 从IDE或通过执行mono ./paket/paket.exe generate-include-scripts

When I run fsharpi App.fsx I get the following error: 当我运行fsharpi App.fsx ,出现以下错误:

/tmp/test/stdin(0,1): error FS0078: Unable to find the file 'FParsecCS.dll' in any of
 /usr/lib/mono/4.5
 /tmp/test/./packages
 /tmp/test
 /usr/lib/cli/fsharp/
System.TypeInitializationException: The type initializer for 'Escaping' threw an exception.
  at Chiron+Formatting+formatObject@728-1.Invoke (System.Tuple`2[T1,T2] tupledArg) [0x0000f] in <57e2953614a049a0a74503833695e257>:0 
  at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x00018] in <566a0818dff9fae1a745038318086a56>:0 
  at Chiron+Formatting+join@667-2[a].Invoke (System.Text.StringBuilder b) [0x00029] in <57e2953614a049a0a74503833695e257>:0 
  at Chiron+Formatting+join@666-1[a].Invoke (Microsoft.FSharp.Collections.FSharpList`1[T] values, System.Text.StringBuilder b) [0x00013] in <57e2953614a049a0a74503833695e257>:0 
  at Microsoft.FSharp.Core.OptimizedClosures+Invoke@3252[T2,TResult,T1].Invoke (T2 u) [0x00001] in <566a0818dff9fae1a745038318086a56>:0 
  at Chiron+Formatting+formatObject@726-6.Invoke (System.Text.StringBuilder x) [0x00013] in <57e2953614a049a0a74503833695e257>:0 
  at Chiron+Formatting+formatObject@726-7.Invoke (System.Text.StringBuilder x) [0x00001] in <57e2953614a049a0a74503833695e257>:0 
  at Chiron+Formatting+formatObject@726-8.Invoke (System.Text.StringBuilder x) [0x00001] in <57e2953614a049a0a74503833695e257>:0 
  at Chiron+Formatting+Json.format (Chiron+Json json) [0x00013] in <57e2953614a049a0a74503833695e257>:0 
  at <StartupCode$FSI_0001>.$FSI_0001.main@ () [0x00046] in <6e3acc116b9749ea9b5dc27663d21170>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0 
Stopped due to error

If you are not on Linux, the error can be reproduced with docker like this: 如果您不在Linux上,则可以使用docker再现错误,如下所示:

docker run -it -v $(pwd):/tmp/ttt fsharp/fsharp bin/bash

Update 更新

Also referencing the assemblies directly does not work: 同样直接引用程序集不起作用:

#r "packages/Aether/lib/net35/Aether.dll" 
#r "packages/FParsec/lib/net40-client/FParsecCS.dll"
#r "packages/FParsec/lib/net40-client/FParsec.dll"
#r "packages/Chiron/lib/net40/Chiron.dll" 

open Chiron

printfn "%A" (Object <| Map.ofList [ "foo", String "bar" ] |> Json.format)

You need to include: 您需要包括:

 #r "packages/FParsec/lib/net40-client/FParsecCS.dll"
 #r "packages/FParsec/lib/net40-client/FParsec.dll"

Too. 太。

You may have run into this issue 您可能遇到了这个问题

Not sure what is missing for you, but using fsharp docker container I was able to run it: 不确定您缺少什么,但是使用fsharp容器,我可以运行它:

#I "packages/FParsec/lib/net40-client/"
- #I "packages/Aether/lib/net35/"     
- #I "packages/Chiron/lib/net40/";;

--> Added '/root/packages/FParsec/lib/net40-client/' to library include path


--> Added '/root/packages/Aether/lib/net35/' to library include path


--> Added '/root/packages/Chiron/lib/net40/' to library include path

> #r "Chiron.dll";;

--> Referenced '/root/packages/Chiron/lib/net40/Chiron.dll' (file may be locked by F# Interactive process)

> open Chiron
- 
- printfn "%A" (Object <| Map.ofList [ "foo", String "bar" ] |> Json.format);;
Binding session to '/root/packages/FParsec/lib/net40-client/FParsecCS.dll'...
Binding session to '/root/packages/FParsec/lib/net40-client/FParsec.dll'...
"{"foo":"bar"}"

val it : unit = ()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM