ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

error FS0193: Operation is not supported on this platform.

Open jkone27 opened this issue 1 year ago • 18 comments

Describe the bug

I have a compiling script in F#

Steps to reproduce

not clear, but sometimes happens in interactive while running the code with ALT-ENTER, not able to reproduce consistently yet.

Link to sample reproduction

Expected behaviour

no errors as the code is valid F# code

Machine info

  • OS: Mac
  • .NET SDK version: 7.0.202
  • Ionide version: 7.5.2

jkone27 avatar Apr 03 '23 13:04 jkone27

I see this phenomenon, too. Linux Mint 20.3, VS Code 1.78.2, Ionide 7.5.4. The following code snippet, sent to an FSI terminal, works with dotnet 6.0.488 installed, but not with 7.0.302 or 8.0.100-preview.4.23260.5:

(* ~\~ language=FSharp filename=src/dnlib-testbed.fsx *)
(* ~\~ begin <<lit/dnlib-testbed.md|src/dnlib-testbed.fsx>>[init] *)
#if INTERACTIVE
(* ~\~ begin <<lit/dnlib-testbed.md|import-nugets>>[init] *)
#r "nuget:Microsoft.CodeAnalysis.CSharp" 
(* ~\~ end *)
(* ~\~ begin <<lit/dnlib-testbed.md|import-nugets>>[1] *)
#r "nuget:dnlib"
(* ~\~ end *)
(* ~\~ begin <<lit/dnlib-testbed.md|import-nugets>>[2] *)
#r "nuget:spkl.Diffs"
(* ~\~ end *)
(* ~\~ begin <<lit/dnlib-testbed.md|import-nugets>>[3] *)
#r "nuget:xunit"
#r "nuget:Unquote"
(* ~\~ end *)
#endif

(* ~\~ begin <<lit/dnlib-testbed.md|import-ms-codeanalysis>>[init] *)
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp
(* ~\~ end *)
(* ~\~ begin <<lit/dnlib-testbed.md|import-dnlib>>[init] *)
open dnlib.DotNet
open dnlib.DotNet.Emit
(* ~\~ end *)
(* ~\~ begin <<lit/dnlib-testbed.md|import-spkl-diffs>>[init] *)
open spkl.Diffs
(* ~\~ end *)
(* ~\~ begin <<lit/dnlib-testbed.md|import-dotnet>>[init] *)
open System
open System.IO
open System.Reflection
open System.Collections.Generic
open System.Text.RegularExpressions
(* ~\~ end *)

It seems to be that it's really the block comments that make Ionide trip:

- (* ~\~ end *)
- (* ~\~ begin <<lit/dnlib-testbed.md|impor

error FS0193: Operation is not supported on this platform.

> -dnlib>>[init] *)

7enderhead avatar May 30 '23 15:05 7enderhead

I had the same with // comments i think

jkone27 avatar May 31 '23 21:05 jkone27

Does this happen only with NET7 and NET8? can someone else check this? i am on MacOS, is there any way to reproduce in tests if there is tests for comment sections? (comments parsed correctly in FSI by ionide)

jkone27 avatar Jun 07 '23 09:06 jkone27

https://github.com/ionide/ionide-vscode-fsharp/blob/f7a2887064a93a6321cfd6d35187e3cc52868ba1/src/Components/Fsi.fs#L39 --> do we have a way to add unit tests?

jkone27 avatar Jun 07 '23 09:06 jkone27

We don't have tests for the Ionide layer itself, but it is possible to test excursions to some degree. I'm not really familiar with it though.

The 'send to FSI' interaction is really simplistic, it's possible that we may need to escape certain syntax when sending it via stdin for example.

baronfel avatar Jun 07 '23 11:06 baronfel

Does this happen only with NET7 and NET8? can someone else check this? i am on MacOS, is there any way to reproduce in tests if there is tests for comment sections? (comments parsed correctly in FSI by ionide)

I have seen the phenomenon in different forms on several machines, and on some it doesn't work with dotnet 6.x either (especially if dotnet is installed via the Linux distribution's package manager system).

I have actually set up a new development Linux machine, and the criterion was whether VS Code/Ionide/dotnet (7) "out of the box" do not exhibit the behavior.

7enderhead avatar Jun 07 '23 15:06 7enderhead

i get it also with this script in fsx when running portions with alt/option + enter

open System

type Message = string * AsyncReplyChannel<string>

let replyAgent =
    MailboxProcessor<Message>.Start(fun inbox ->
    let rec loop () =
        async {
            let! (message, replyChannel) = inbox.Receive()
            replyChannel.Reply(String.Format("Received message: {0}", message))
            do! loop ()
        }
    loop ())

replyAgent.PostAndReply(fun rc -> "Hello", rc)

macos net7 SDK lts

dotnet --version
7.0.401

jkone27 avatar Sep 28 '23 20:09 jkone27

There are two issues about similar errors in the fsharp repo:

https://github.com/dotnet/fsharp/issues/14160 https://github.com/dotnet/fsharp/issues/14946

TheAngryByrd avatar Sep 28 '23 21:09 TheAngryByrd

I'm able to workaround this by adding the --readline- parameter to my user settings:

    "FSharp.fsiExtraParameters": [
        "--readline-"
    ],

HoraceGonzalez avatar Oct 11 '23 18:10 HoraceGonzalez

doesn't fully solve for me, the error is gone but in ionide still hangs with no completion, even after #quit;; and re-send to interactive with option/alt + enter

jkone27 avatar Oct 14 '23 13:10 jkone27

image still have this issue... does other people have this? I am on macOS and dotnet 8 latest ionide v7.17.0

jkone27 avatar Jan 19 '24 09:01 jkone27

Same issue for me when running on linux. It happens when the terminal window is not large enough to fit the sent line. If the line fits, it works fine. Usually I'm experiencing this issue when casting my screen and zooming vscode. Not sure it´s an issue inside ionide or if it's related to this one https://github.com/microsoft/vscode/issues/100225

On Fri, Jan 19, 2024 at 10:53 AM jkone27 @.***> wrote:

image.png (view on web) https://github.com/ionide/ionide-vscode-fsharp/assets/10419217/b3d18acd-6324-4f9c-a45f-890a79fb4d00 still have this issue... does other people have this? I am on macOS and dotnet 8 latest ionide v7.17.0

— Reply to this email directly, view it on GitHub https://github.com/ionide/ionide-vscode-fsharp/issues/1859#issuecomment-1900089560, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB35CSOSFIXC5H3NI2DJETYPI7B7AVCNFSM6AAAAAAWRKCB6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBQGA4DSNJWGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Titaye avatar Jan 19 '24 11:01 Titaye

@Titaye that's really useful info! I had no idea the terminal pane could impact things to this degree.

baronfel avatar Jan 19 '24 14:01 baronfel

I can confirm that the size of the terminal can have this impact. I was actually seeing this behaviour without knowing it as I always resized my terminal when a line that I paste in it is too long and not interpreted correctly.

MangelMaxime avatar Jan 19 '24 20:01 MangelMaxime

It looks like there may be some API we can use to get the dimensions of the terminal: https://github.com/microsoft/vscode/pull/67919

This might be usable to modify the message we send to make it usable by the terminal.

baronfel avatar Jan 19 '24 20:01 baronfel

I don't think we can easily reformat the code sent.

Imagine we have this code:

let x = DateTime(2014, 7, 1, 16, 37, 0, DateTimeKind.Utc).ToString("""r \\\zz""", CultureInfo.InvariantCulture)
                                            ^

and the terminal can accept up to the ^ character. How would we cut that line?

Perhaps, detecting the size of the terminal and generating a message box to explain that the terminal is too small or that the line at X is too long is possible solution if we can't reformat the line of code.

MangelMaxime avatar Jan 19 '24 21:01 MangelMaxime

in extreme cases we could ask fantomas to reformat it with a given maximum width, but yeah it's probably impossible to do correctly in the general case.

starting to sound like something that we can't truly fix until/unless we move away from dotnet fsi usage directly and into managing a series of FsiEvaluationSessions inside FSAC or something.

baronfel avatar Jan 19 '24 21:01 baronfel