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

Fake does not find dotnet fsi for Fsi.exec targets. #2561

Closed
nhirschey opened this issue Dec 15, 2020 · 5 comments
Closed

Fake does not find dotnet fsi for Fsi.exec targets. #2561

nhirschey opened this issue Dec 15, 2020 · 5 comments

Comments

@nhirschey
Copy link

nhirschey commented Dec 15, 2020

Description

Fake does not find new versions of fsi on windows. FsiTool.Internal works, but FsiTool.Default and FsiTool.External "dotnet fsi" fail.

Repro steps

  1. Install a new version of fsi
    • If installed via Visual Studio 2019 16.8 Community, it will be in [ProgramFilesX86]/Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp
    • If installed via dotnet 5.0.100 it will be in [ProgramFiles]dotnet\sdk\5.0.100\FSharp.
  2. Try to run Fsi.exec id "testscript.fsx" [] or Fsi.exec (fun p -> {p with FsiTool.External "dotnet fsi"}) "testscript.fsx" [] in a fake build.fsx script.

Expected behavior

I expect fake to run testscript.fsx

Actual behavior

The target fails with the error (Start of process 'fsi.exe' failed.) or (Start of process 'dotnet fsi' failed.).

The problem is the fsi path searching here: https://github.com/fsharp/FAKE/blob/release/next/src/app/Fake.DotNet.Fsi/Fsi.fs#L249

To find the latest dotnet fsi, it will probably be necessary to update ProcessUtils.findFilesInternal so that it searches C:\Program Files\dotnet\sdk for the latest sdk.

Known workarounds

Fsi.exec (fun p -> {p with FsiTool.Internal}) "testscript.fsx" [] works.

Related information

  • Windows 10
  • Dotnet 5.0.100
  • Version of FAKE (4.X, 5.X) : 5.20.3
@github-actions
Copy link

Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!

@github-actions
Copy link

There has not been any activity in this issue for the last 3 months so it will be closed in 14 days if there is no activity.

@nhirschey
Copy link
Author

still an issue

@rynoV
Copy link

rynoV commented Mar 28, 2024

Update: Actually it seems like the below issue was just because I was using the wrong TargetProfile


I'm also running into this issue. In my case FsiTool.Internal also doesn't work

Starting task 'Fsi ': internal fsi with args ["C:\fsi.exe"; "--load:snap_dataset.fsx"; "--debug:pdbonly";
 "--targetprofile:mscorlib"; "--exec"; "--"]
Unhandled exception. Fake.Core.BuildFailedException: Target 'CheckSnapDataset' failed.
 ---> System.AggregateException: One or more errors occurred. (Error creating evaluation session: StopProcessingExn)
 ---> System.Exception: Error creating evaluation session: StopProcessingExn
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1448.Invoke(String message)
   at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, Boolean fsiCollectible, FSharpOption`1 legacyReferenceResolver) in D:\a\_work\1\s\src\fsharp\fsi\fsi.fs:line 3262
   at Fake.DotNet.Fsi.InternalFsi.doExec(String script, FSharpList`1 allArgs) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.Fsi\Fsi.fs:line 394
   at Fake.DotNet.Fsi.InternalFsi.exec(String script, FSharpList`1 allArgs) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.Fsi\Fsi.fs:line 408
   at Fake.DotNet.Fsi.execRaw(FSharpFunc`2 fsiParams, String script, FSharpList`1 scriptArgs) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.Fsi\Fsi.fs:line 429
   at Fake.DotNet.Fsi.exec(FSharpFunc`2 fsiParams, String script, FSharpList`1 scriptArgs) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.Fsi\Fsi.fs:line 460

Seems related to fsharp/fsharp-compiler-docs#807 and maybe dotnet/fsharp#11770

@rynoV
Copy link

rynoV commented Mar 28, 2024

Internal doesn't seem to respect WorkingDirectory

I hacked External like this for now

diff --git a/Build/Fsi.fs b/Build/Fsi.fs
--- a/Build/Fsi.fs	(revision eb8500c3ee49ba79594a49077974bd2f9e0f935c)
+++ b/Build/Fsi.fs	(date 1711662199284)
@@ -49,6 +48,7 @@
 
     [<RequireQualifiedAccess>]
     type FsiTool =
+        /// Use an empty string to use `dotnet fsi`
         | External of string
         | Internal
         | Default
@@ -357,7 +357,7 @@
 
             let messageF msg = results.Add msg
 
-            let processResult =
+            let mutable proc =
                 CreateProcess.fromRawCommandLine fsiExe args
                 |> CreateProcess.withEnvironment (
                     defaultEnvironmentVars |> List.append (parameters.Environment |> Map.toList)
@@ -366,7 +366,11 @@
                 |> CreateProcess.withTimeout TimeSpan.MaxValue
                 |> CreateProcess.redirectOutput
                 |> CreateProcess.withOutputEventsNotNull messageF errorF
-                |> Proc.run
+
+            if String.IsNullOrWhiteSpace fsiExe then
+                proc <- proc |> DotNet.prefixProcess id [ "fsi" ]
+
+            let processResult = proc |> Proc.run
 
             if processResult.ExitCode <> 0 then
                 List.iter Trace.traceError (errors |> List.ofSeq)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants