Paul Young
Paul Young

Reputation: 1477

Why does my F# project build locally but fail on Travis?

The build for my project is failing on Travis with the following error:

FSC: error FS0193: The module/namespace 'System.Net' from compilation unit 'System' did not contain the namespace, module or type 'WebClient'

The main project doesn't have any dependencies, and the test project doesn't depend on System.Net or WebClient, so I'm not sure how that applies here.

Everything works fine locally, so I'm assuming a version mismatch somewhere but haven't been able to identify what.

The output of my local build can be found in this text file.


Update

Following the GitHub issue created by @7sharp9 it was discovered that this is a Mono packaging bug.

The suggested workaround was to reference FSharp.Core from the NuGet package instead, which worked for me.

You may wish to only use the NuGet package when the canonical path is unavailable, as I did.

Upvotes: 13

Views: 1077

Answers (1)

7sharp9
7sharp9

Reputation: 2167

The travis version is building with an FSharp.Core from the GAC:

-r:/usr/lib/mono/gac/FSharp.Core/4.3.1.0__b03f5f7f11d50a3a/FSharp.Core.dll

Whereas your local build is using the FSharp.Core at:

-r:"/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll"

The error you are getting:

FSC: error FS0193: The module/namespace 'System.Net' from compilation unit 'System' did not contain the namespace, module or type 'WebClient'

Indicated a mismatched FSharp.Core where its trying to resolve System.Net references from the Fsharp.Core located in the GAC, the other references in your project are all PCL 259 which will not satisfy this reference.

As to why, could you get travis to build using the diagnostic switch?

Ok so following on, now that there is a diagnostic build linked, the problem is here:

HintPath /usr/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll does not exist. Reference FSharp.Core resolved to /usr/lib/mono/gac/FSharp.Core/4.4.0.0__b03f5f7f11d50a3a/FSharp.Core.dll. CopyLocal = False Reference found at search path {GAC}

The travis instance does not have:

/usr/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll

So it reverts to the gac.

There was a recent issue where FSharp.Core was not installed to the correct location, maybe this is a manifestation of that.

What I would do is try a different version of mono as described here: http://docs.travis-ci.com/user/languages/csharp/ Maybe try an older one like 3.12 or alpha or beta to try and confirm that this is indeed the issue.

Upvotes: 12

Related Questions