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

Console.Out needs to be redirected to get FsiEvaluationSession output in correct order (was FCS 0.0.59 shows help at the end) #201

Closed
forki opened this issue Aug 25, 2014 · 17 comments

Comments

@forki
Copy link
Member

forki commented Aug 25, 2014

image

After updating FAKE to FCS 0.0.59 (see fsprojects/FAKE#519) it shows the FSI help at the end of a script.
Any ideas why?
@tpetricek @dsyme @sergey-tihon

@sergey-tihon
Copy link
Contributor

I also found this today in the response from FAKE.Deploy.

@dungpa
Copy link
Contributor

dungpa commented Aug 25, 2014

Could it be the problem because you upgrade to Visual F# Tools 3.1.2? I started seeing it in AppVeyor builds after they upgraded to Visual F# Tools 3.1.2 https://ci.appveyor.com/project/dungpa/visualfsharppowertools/build/1.5.0-a1408251942.

@forki
Copy link
Member Author

forki commented Aug 25, 2014

This would be even worse.
On Aug 25, 2014 10:28 PM, "Anh-Dung Phan" notifications@github.com wrote:

Could it be the problem because you upgrade to Visual F# Tools 3.1.2? I
started seeing it in AppVeyor builds after they upgrade to Visual F# Tools
3.1.2
https://ci.appveyor.com/project/dungpa/visualfsharppowertools/build/1.5.0-a1408251942
.


Reply to this email directly or view it on GitHub
#201 (comment)
.

@sergey-tihon
Copy link
Contributor

@dungpa but your build script also use new version of FAKE 3.3.0 that built on top of FCS 0.0.59.

@dungpa
Copy link
Contributor

dungpa commented Aug 25, 2014

You're right. My bad. I didn't notice that FAKE 3.3.0 has just been released today.

@forki
Copy link
Member Author

forki commented Aug 25, 2014

Yes. It's probably the new FCS. Still weird issue
On Aug 25, 2014 11:13 PM, "Anh-Dung Phan" notifications@github.com wrote:

You're right. My bad. I didn't notice that FAKE 3.3.0 has just been
released today.


Reply to this email directly or view it on GitHub
#201 (comment)
.

@forki
Copy link
Member Author

forki commented Aug 26, 2014

Now I think It's not FCS. It's probably fsprojects/FAKE@a364933#diff-ee58d9452be1f275ad4acc98277247a3R127

@sergey-tihon
Copy link
Contributor

Ok... but without this line you do not get output in the case of success execution, don't it?
handleMessages catch output and show to the user. Since it is yellow - it is data from outStream...
I thought that it is OK that FAKE shows as all output, and question is why FCS prints this data into output stream. Am I right?

@forki
Copy link
Member Author

forki commented Aug 26, 2014

mhm I see two solutions:

  • Remove this line from FAKE (at least a fast temporary fix)
  • Remove the "old" FSI output from FCS (I don't think it makes sense in FCS)

@forki
Copy link
Member Author

forki commented Aug 26, 2014

I did the first one - fsprojects/FAKE@d1b9226

Anybody up for the second?

@sergey-tihon
Copy link
Contributor

I recompiled FAKE using new FAKE and the message disappeared.

@7sharp9
Copy link
Member

7sharp9 commented Sep 11, 2014

Is this still an issue?

@sergey-tihon
Copy link
Contributor

Yes, FCS still prints this messages.

@fsgit fsgit added the bug label Sep 16, 2014
@fsgit
Copy link
Contributor

fsgit commented Sep 16, 2014

@sergey-tihon Could you please add a repro for this that involves FCS alone (not FAKE)?

@sergey-tihon
Copy link
Contributor

helloworld.fsx script

printfn "Hello world"
2+2

demo.fsx script

#r "FSharp.Compiler.Service.dll"

open System
open System.IO
open Microsoft.FSharp.Compiler.Interactive.Shell

let main () =
    let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()
    let commonOptions = [| "fsi.exe"; "--noninteractive" |]

    let sbOut = Text.StringBuilder()
    use outStream = new StringWriter(sbOut)
    use stdin = new StreamReader(Stream.Null)

    let session = FsiEvaluationSession.Create(fsiConfig, commonOptions, stdin, outStream, outStream)

    session.EvalScript @"d:\Downloads\fsharp.compiler.service.0.0.62.nupkg\lib\net45\helloworld.fsx"

    printfn "%s" (sbOut.ToString())

main()

Result of execution:

Hello world

F# Interactive for F# 3.1 (private)
Freely distributed under the Apache 2.0 Open Source License

For help type #help;;

> [Loading d:\Downloads\fsharp.compiler.service.0.0.62.nupkg\lib\net45\helloworld.fsx]

namespace FSI_0001


val it : unit = ()

@dsyme
Copy link
Contributor

dsyme commented Nov 5, 2014

This is not strictly speaking a bug. The sbOut stream captures all the diagnostics from the FsiEvaluationSession, including the banner text. The printfn in the script goes to Console.Out (which is not automatically redirected).

I adjusted the script to also capture Console.Out and things seemed to work correctly:

    let origout = System.Console.Out
    try 
      System.Console.SetOut outStream

      let session = FsiEvaluationSession.Create(fsiConfig, commonOptions, stdin, outStream, outStream)

      session.EvalScript @"hello.fsx"
    finally 
      System.Console.SetOut origout

@dsyme
Copy link
Contributor

dsyme commented Nov 5, 2014

Given this I think we can probably close this, though the behaviour is a bit strange.

@fsgit fsgit changed the title FCS 0.0.59 shows help at the end Console.Out needs to be redirected to get FsiEvaluationSession output in correct order (was FCS 0.0.59 shows help at the end) Nov 5, 2014
matthid added a commit to matthid/Yaaf.FSharp.Scripting that referenced this issue Apr 25, 2015
@dsyme dsyme closed this as completed Oct 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants