VSCode errors with user input readline()

Hello, I hope you are all doing well
I’ve really been enjoying Julia, and it’s been taking the place of Java in my focused language, but I’ve been having some problems with user inputs in VSCode (Vers. 1.63.2 on Windows 11), Julia (Vers. 1.7)

Using this code as an example:

println("Please enter a number")
num = parse(Int, readline())
println("Thank you for entering $num")

I am given my prompt, and can input a number, but when I press enter for my number, it continues to prompt for input, and when I press enter (or type anything) I get the error:

This continues with or without parsing separately, and inside of functions.
If I seek out a String, and ignore parsing I end up getting
`UndefVarError: testinputstring not defined"

When I test either of these in the Julia REPL without VSCode, they work fine with no issues

I’m wondering what may be the source of the issue, and what solutions may be? I seem to find a similar issue for people using Juno, but in older versions of Julia

Thank you so much

How are you executing this code in the VSCode REPL? Copy and paste?

The argument error is what you would expect if someone just pressed “Enter”.

What happens if you manually enter parse(Int, readline())?

readline() might be broken in VS Code - see this post.

2 Likes

Better to have the link to the direct bug issue.
Also because there you can have a sort of workaround:

  • evaluate inline the readline command
  • go to the terminal area of VSCODE
  • type a space and enter a first time, and then the answer you want to give and enter again
    The answer should now accounted for in the readline call.

I know it’s pretty ugly, but it can help while developing an old-style script-based application, if then the “user” is not supposed to use VSCODE itself…

FWIW, it works fine here on VS Code Julia extension v1.5.10, and Julia v"1.7.1" on Win11

Still it is not fixed even julia v1.10.3, maybe it is an entry barriers to python users. How about to show warning message, at least? I guess no beginer can notice that it is just bug and will never fixed.