-
Notifications
You must be signed in to change notification settings - Fork 157
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
fsi variable is unavailable when parsing script files #227
Comments
Pinging @dsyme since this involves some hairy stuff that isn't limited to FSAC, and I'm not sure what the best course of action is. I've tracked this down to (as usual) Mono vs. the CLR, combined with FCS's procedures for determining the "default F# binary path", which ultimately results in The problem code is let BinFolderOfDefaultFSharpCompiler(probePoint:string option) =
#if FX_NO_WIN_REGISTRY
ignore probePoint
#if FX_NO_APP_DOMAINS
Some System.AppContext.BaseDirectory
#else
Some System.AppDomain.CurrentDomain.BaseDirectory // <- OUR PROBLEM
#endif
#else
// a zillion other ways to try to find the bin path Since the assembly we need doesn't get bundled by FSAC (i.e. is not in the same directory as // Check for an app.config setting to redirect the default compiler location
// Like fsharp-compiler-location
try
// FSharp.Compiler support setting an appkey for compiler location. I've never seen this used.
let result = tryAppConfig "fsharp-compiler-location"
match result with
| Some _ -> result
| None ->
let safeExists f = (try File.Exists(f) with _ -> false)
// Look in the probePoint if given, e.g. look for a compiler alongside of FSharp.Build.dll
match probePoint with
| Some p when safeExists (Path.Combine(p,"FSharp.Core.dll")) -> Some p
| _ -> // continues to look, via the registry Our let defaultFSharpBinariesDir = FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(Some(typeof<FSharpCheckFileAnswer>.Assembly.Location)).Value ...which comes from FSAC asks to parse the contents of a I can think of a few options to fix this:
|
I am somewhat in favor of maybe because i prefer I have a related issue trying to find the reference assemblies on .net core parsing an fsx, and i am really really tired of this. FCS ihmo is a lower level, and shouldnt care about this stuff, just use the reference list passed |
Do you mean having FSAC ask msbuild, or having FCS ask? There's already plenty of magic resolution in FCS (as outlined/ranted), but doing it there has the benefit of fixing it for FCS clients--though the value may be dubious, as it just adds yet more magic resolution stuff. I defer to you/others here, since you have a better picture of how this plays out for consumers of FCS besides just FSAC. |
Having FSAC ask.. too difficult change FCS for me atm. I'd like to use Is not the Instead of magic resolution of fsi references inside FCS, what i want to do is:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Core" />
<!-- // These are the Portable-profile and .NET Standard 1.6 dependencies of FSharp.Core.dll. These are needed
// when an F# sript references an F# profile 7, 78, 259 or .NET Standard 1.6 component which in turn refers
// to FSharp.Core for profile 7, 78, 259 or .NET Standard. -->
<Reference Include="System.Runtime" /> <!-- // lots of types -->
<Reference Include="System.Linq" /> <!-- // System.Linq.Expressions.Expression<T> -->
<Reference Include="System.Reflection" /> <!-- // System.Reflection.ParameterInfo -->
<Reference Include="System.Linq.Expressions" /> <!-- // System.Linq.IQueryable<T> -->
<Reference Include="System.Threading.Tasks" /> <!-- // valuetype [System.Threading.Tasks]System.Threading.CancellationToken -->
<Reference Include="System.IO" /> <!-- // System.IO.TextWriter -->
<!-- //yield "System.Console" // System.Console.Out etc. -->
<Reference Include="System.Net.Requests" /> <!-- // System.Net.WebResponse etc. -->
<Reference Include="System.Collections" /> <!-- // System.Collections.Generic.List<T> -->
<Reference Include="System.Runtime.Numerics" /> <!-- // BigInteger -->
<Reference Include="System.Threading" /> <!-- // OperationCanceledException -->
<!-- // always include a default reference to System.ValueTuple.dll in scripts and out-of-project sources
match GetDefaultSystemValueTupleReference() with
| None -> ()
| Some v -> yield v -->
<Reference Include="System.Web" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Numerics" />
<!-- "-r:C:\Windows\Microsoft.NET\assembly\GAC_MSIL\FSharp.Compiler.Interactive.Settings\v4.0_4.4.0.0__b03f5f7f11d50a3a\FSharp.Compiler.Interactive.Settings.dll"|]; -->
<Reference Include="FSharp.Core" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="_GetFsxScriptReferences" DependsOnTargets="ResolveAssemblyReferences">
<Message Text="V: %(ReferencePath.Identity)" />
<WriteLinesToFile
Condition=" '$(_GetFsxScriptReferences_OutFile)' != '' "
File="$(_GetFsxScriptReferences_OutFile)"
Lines="@(ReferencePath -> '%(Identity)')"
Overwrite="true"
Encoding="UTF-8"/>
<!-- WriteLinesToFile doesnt create the file if @(ReferencePath) is empty -->
<Touch
Condition=" '$(_GetFsxScriptReferences_OutFile)' != '' "
Files="$(_GetFsxScriptReferences_OutFile)"
AlwaysCreate="True" />
</Target>
</Project> now you can run:
at will, to get the reference assemblies for these files, like
so something similar to try find that settings.dll too |
OK, that's what I thought. One problem with this, though, is that while we can expect that msbuild/xbuild exists somewhere, it won't necessarily be in the user's |
FWIW, I just took a local copy of Might make sense to just create a NuGet package for this and reference it that way. |
That's an even better suggestion if it's tenable. It completely didn't occur to me that much of this stuff is shipped via NuGet nowadays. If someone can vouch that it isn't e.g. tied to specific F# versions (it's nice that FSAC has backwards compatibility), that sounds like the way to go--it could just be part of pushing FCS releases. |
Happen also on windows, with fresh install because new VS 15.x doesnt put anymore that assembly in GAC -> same error. |
I figured it had the ability to break elsewhere (which was why I gave the rundown of how it attempts to search), and I'm not surprised to hear it is, since there are so many ways it can appear to work on one person's system but not on another. We should try to get an answer re: whether that assembly can ship with FCS; it definitely seems the easiest solution, and it's definitely bad for this to appear totally broken to people who can't diagnose it themselves. |
Anthoer possibility is to add the assembly from fsi location. |
This seems wrong to me :) I think you would be better off using the symlink at |
This breaks on all platforms. We should strictly avoid, as much as possible, doing anything that gets into visualfsharp-vs.-fsharp, CLR vs. Mono, or other platform-specific details--the reason we are dealing with this bug at all is because of the fragility and needless complexity of all this code we have for probing where stuff might live. Can someone determine whether it's practical to distribute |
Wow. I should just have looked myself. Here is everything comprising https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSInteractiveSettings.txt Who do we need to poke to get this tossed up on NuGet somewhere? |
It seems reasonable for someone to create a nuget of FSharp.Compiler.Interactive.Service.dll and distribute it with FSAC, Any application such as FSAC built using FSharp.Compiler.Service.dll that wants to typecheck scripts needs a copy of that DLL, you may as well just distribute it with the application. |
Any updates on this issue? I'm really new to .net / f# , coming from js/python but I like f# and i'm trying to learn it in my spare time. I'm going over the stuff in fsharpforfunandprofit and one of the first examples involves running this code from an fsx script.
I'm using vcode with ionide on Ubuntu 18 and the error appearing in the editor is
Any details on how to fix this? Thanks... |
And here is the 2019 reminder :) |
Solved as part of #466, yay! |
With FSAC 0.34.0 and F# 4.1.18 on Linux:
Notice that it works if you explicitly reference
FSharp.Compiler.Interactive.Settings.dll
--but you should not have to do this. With the same version of FSAC running on the CLR on Windows,FsiBug.fsx
parses fine, which is the correct/expected behavior.Mono version info, just in case it's useful:
The text was updated successfully, but these errors were encountered: