Repository navigation
Closed
Description
I came across the following crash when upgrading FSharp.Formatting in the mbrace-docs repository:
Generating 'c:\Users\eirik\Development\mbrace\mbrace-docs\docs\tools\..\content/azure-tutorial.html'
System.MethodAccessException: Attempt by method 'FSharpVSPowerTools.Lexer.|GenericTypeParameterPrefix|StaticallyResolvedTypeParameterPrefix|Other|@92(System.String, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpTokenInfo)' to access method 'Microsoft.FSharp.Compiler.Parser.tokenTagToTokenId(Int32)' failed.
at FSharp.CodeFormat.CodeFormatAgent.ParseSource(String file, String source, FSharpOption`1 options, FSharpOption`1 defines) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.CodeFormat\CodeFormatAgent.fs:line 390
at FSharp.Literate.ParseScript.parseScriptFile(String file, String content, CompilerContext ctx) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Literate\ParseScript.fs:line 198
at FSharp.Literate.Literate.ParseScriptFile[d](String path, FSharpOption`1 formatAgent, FSharpOption`1 compilerOptions, FSharpOption`1 definedSymbols, FSharpOption`1 references, FSharpOption`1 fsiEvaluator) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 67
at FSharp.Literate.Literate.ProcessScriptFile(String input, FSharpOption`1 templateFile, FSharpOption`1 output, FSharpOption`1 format, FSharpOption`1 formatAgent, FSharpOption`1 prefix, FSharpOption`1 compilerOptions, FSharpOption`1 lineNumbers, FSharpOption`1 references, FSharpOption`1 fsiEvaluator, FSharpOption`1 replacements, FSharpOption`1 includeSource, FSharpOption`1 layoutRoots, FSharpOption`1 generateAnchors, FSharpOption`1 assemblyReferences, FSharpOption`1 customizeDocument) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 167
at <StartupCode$FSharp-Literate>[email protected](String file, String output) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 184
at <StartupCode$FSharp-Literate>.$Main.processDirectory@199(FSharpOption`1 format, Boolean processRecursive, FSharpFunc`2 processScriptFile, FSharpFunc`2 processMarkdown, String indir, String outdir) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 218
at FSharp.Literate.Literate.ProcessDirectory(String inputDirectory, FSharpOption`1 templateFile, FSharpOption`1 outputDirectory, FSharpOption`1 format, FSharpOption`1 formatAgent, FSharpOption`1 prefix, FSharpOption`1 compilerOptions, FSharpOption`1 lineNumbers, FSharpOption`1 references, FSharpOption`1 fsiEvaluator, FSharpOption`1 replacements, FSharpOption`1 includeSource, FSharpOption`1 layoutRoots, FSharpOption`1 generateAnchors, FSharpOption`1 assemblyReferences, FSharpOption`1 processRecursive, FSharpOption`1 customizeDocument) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 181
at FSI_0003.processDir@88(String topdir) in c:\Users\eirik\Development\mbrace\mbrace-docs\docs\tools\generate.fsx:line 93
at FSI_0003.buildDocumentation() in c:\Users\eirik\Development\mbrace\mbrace-docs\docs\tools\generate.fsx:line 85
at <StartupCode$FSI_0003>.$FSI_0003.main@() in c:\Users\eirik\Development\mbrace\mbrace-docs\docs\tools\generate.fsx:line 105
Stopped due to error
Metadata
Metadata
Assignees
Labels
No labels
Activity
dsyme commentedon Sep 10, 2015
FCS 1.4.0.4 is not binary compatible with previous versions because some things have been made internal. FSharp.Formatting uses a version constraint ">= 0.0.87" for FCS which is inherently dangerous since binary compat has never really been promised for FCS. I think a constraint ">= 0.0.87" and "<= 1.3.0.2" will work OK though in practice
tpetricek commentedon Sep 10, 2015
I guess we should just update FSharp.Formatting to use the latest version then. But we are also relying on Visual F# PowerTools, so we might need to wait for them first...
In the meantime, is there a way to specify range in a nuspec file?
dsyme commentedon Sep 10, 2015
Note 1.4 is for F# 4.x support. That might not be what you want when processing scripts as it may induce dependencies on having FSHarp.Core 4.4.0.0 available, at least check for that. (The default behaviour should be to look at the FSharp.Core referenced by the ultimate host .EXE of the DLL, which sounds sensible, but be careful!)
tpetricek commentedon Sep 12, 2015
I see, didn't realize this is for F# 4.x. I'm testing a fix (specifying range in the NuGet package)
tpetricek commentedon Sep 12, 2015
Ok, new version of F# formatting fixes this, but there is a big but....
If you are using Paket, you need to explicitly tell it that you want at least the current version of F# Formatting:
As we did not have the constraint before, there is another valid resolution which is to get the latest F# Compiler Service and older release of F# Formatting. This will not work - but I think there is no way to prevent this - because the new incompatible version of FCS has a higher version :-(
tpetricek commentedon Sep 12, 2015
Actually, maybe you only run into the issues if you also explicitly require FCS, which was the case in my project, which had:
So, this should be OK for normal uses...
CumpsD commentedon Oct 13, 2015
I am resolving into this:
However I am still getting the same error
What do I exactly need to do to fix this?
forki commentedon Oct 13, 2015
not sure, but would releasing #345 help?
CumpsD commentedon Oct 13, 2015
Here are the relevant files which cause it:
https://github.com/exira/ges/blob/ca747a75b544259b714af65cf6535b776360296a/paket.dependencies
https://github.com/exira/ges/blob/ca747a75b544259b714af65cf6535b776360296a/paket.lock
That repo
build.cmdright now fails on it. (commit ca747a75b544259b714af65cf6535b776360296a)CumpsD commentedon Oct 13, 2015
@forki perhaps, if I ran with this it worked:
but I wanted to upgrade FSharp.Formatting :)
forki commentedon Oct 13, 2015
yeah but paket can't do magic. if stuff is in compatible we need to express this in the dependencies.
CumpsD commentedon Oct 13, 2015
Does this issue need to be reopened then? Since the current dependencies actually don't work?
forki commentedon Oct 13, 2015
Yes it's breaking other things too. Like fsreveal
On Oct 13, 2015 7:39 PM, "David Cumps" [email protected] wrote:
30 remaining items
tpetricek commentedon Oct 18, 2015
Thanks everyone for going through the additional test cases. Now I'm really puzzled what change in FAKE is doing this...
I tried printing the version of FCS loaded in current
AppDomainin FAKE 4.5.4 and it still prints the 1.4 version of FCS (but then it works....)matthid commentedon Oct 18, 2015
Can confirm but not explain this ...
Maybe FAKE.exe runs in a security context where it is allowed to access internal methods, that would at least explain how it can sometimes work at all... Maybe the context sometimes changes depending on how assemblies are build (the only difference in 4.5.4 and 4.5.5 is adding groups and
paket updatefsprojects/FAKE@4.5.4...4.5.5)To close this issue we should release a version compatible with latest FAKE (ie update to powertools 2.1.0 and latest
Fsharp.Compiler.Service)The only safe option to prevent this error for now are (at least as far as I can understand this currently):
Maybe we should somehow detect a valid fake version and fail early if we are not compatible?
tpetricek commentedon Oct 18, 2015
Yeah, we should definitely update F# Formatting to latest versions.. but I would still like to understand why this is happening.
Looks like there was no relevant change in FAKE, so perhaps this is something that has been caused by an update of FCS from version 1.4.0.1 to version 1.4.0.6. Perhaps there was some change there that affected how assemblies are loaded in FSI evaluator....?
tpetricek commentedon Oct 18, 2015
Looks like FCS does not have a tag on GitHub for 1.4.0.1, but here are the changes between 1.4.0.2 and 1.4.0.6: fsharp/fsharp-compiler-docs@1.4.0.2...1.4.0.6
paket update (fixes #337)
matthid commentedon Oct 18, 2015
definitely...
1.4.0.3 was the first version where the methods where made internal (https://github.com/fsharp/FSharp.Compiler.Service/blob/master/RELEASE_NOTES.md#1403--). This is what @dsyme was mentioning on his first post. So I think that's the solution to the mystery? It works until FAKE-4.5.4 because it uses FSharp.Compiler.Service < 1.4.0.3 and doesn't work on later versions.
Funny change for a patch level version number increase :).
However this bug also shows that locking our versions in the package doesn't really solve anything for us when running within FAKE. Maybe we should figure out a way to solve this eventually, when we are hit by this again (Spawning our own AppDomain?).
tpetricek commentedon Oct 18, 2015
Ah, I see... so really, when running inside FAKE, we always end up running against the FAKE version of F# Compiler Service... Well that's a bummer.
I guess that's what @forki was trying to solve by internalizing F# Compiler Service, so that we can load our own version.
This is all a bit silly, but at least I get it now :)
matthid commentedon Oct 18, 2015
Another idea would be to move
FSharp.Formattingfrom the build into the main dependency group of FAKE, this would ensure that FAKE is updatingFSharp.Compiler.Serviceonly when we update it here.@forki would you accept such a change in FAKE? That's not really in the spirit of paket groups and
FSharp.Formattingis not a dependency ofFAKEAND most important other projects can't really do the same (it is not the correct solution but a hack imho)Edit: It's ironic that this couldn't happen before introducing paket groups :)
Merge pull request #348 from tpetricek/update_dependencies
tpetricek commentedon Oct 18, 2015
Wait - I'm not sure I understand - how is this related to Paket groups? (I thought the issue is just that FAKE comes with FCS and now it happens to come with one that's not compatible with F# Formatting...)
forki commentedon Oct 19, 2015
Yes, but by putting fsf into the main group FAKE's own dependency file
would work. Then paket would resolver a FCS that is compatible to fsf. And
we would ship that version with FAKE.
On Oct 18, 2015 21:41, "Tomas Petricek" [email protected] wrote:
forki commentedon Oct 19, 2015
I'm actually ok with that and would accept pr
On Oct 19, 2015 09:17, "Steffen Forkmann" [email protected] wrote:
matthid commentedon Oct 19, 2015
I have one more idea: What about adding FAKE as a dependency of FSharp.Formatting? That should work as well and is a better solution imho (as we really do depend on FAKE in the projectscaffold use-case). Ideally we would not add the dependency to the library package and only to a "scripting" package. But it should not do any harm either (an additional download in the worst case). For FAKE it would lead to slower adoption rates for new versions (as everyone needs to wait for a FSF update).
This solution assumes that people have FSharp.Formatting and FAKE in the same paket group...
forki commentedon Oct 19, 2015
2015-10-19 18:01 GMT+02:00 Matthias Dittrich [email protected]: