Search code examples
macosvisual-studio-codef#mono

How do I use FSI for F# 4 in my visual studio code?


The terminal in my Visual Studio keeps saying F# Interactive for F# 3.1 (Open Source Edition)

How do I tell visual studio to use FSI for F# 4 ?

PS: Visual studio code and all extensions are already updated.

PPS: I am using mac

enter image description here


Solution

  • The Terminal within VSC is using your default shell, and thus will pickup the same path and thus fsharpi will be the same as if you ran it via Terminal.app or iTerm2.app.

    If you have latest Mono version installed, it will place a fsharpi shell script in:

    >which fsharpi
    /usr/local/bin/fsharpi
    

    Which in turn uses mono to execute in the fsi.exe CIL-assembly from:

    /Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/4.5
    

    Mono version 4.6.0 currently installs F# Interactive for F# 4.1

    Grab the latest OS-X Mono version here.

    Run:

    cat `which fsharpi` 
    

    Mine returns:

    #!/bin/sh
    EXEC="exec "
    
    if test x"$1" = x--debug; then
       DEBUG=--debug
       shift
    fi
    
    if test x"$1" = x--gdb; then
       shift
       EXEC="gdb --eval-command=run --args "
    fi
    
    if test x"$1" = x--valgrind; then
      shift
      EXEC="valgrind $VALGRIND_OPTIONS"
    fi
    
    # Beware this line must match the regular expression " (\/.*)\/fsi\.exe" when fsi.exe is fsi.exe.
    # That's because the FSharp MonoDevelop addin looks inside the text of this script to determine the installation
    # location of the default FSharp install in order to find the FSharp compiler binaries (see
    # fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerLocationUtils.fs). That's a pretty unfortunate
    # way of finding those binaries. And really should be changed.
    $EXEC /Library/Frameworks/Mono.framework/Versions/4.6.0/bin/mono $DEBUG $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/4.5/fsi.exe --exename:$(basename "$0") "$@"