Julia println() not printing/inconsistent behavior

1k views Asked by At

This is probably a beginner question, but I could not find anything relevant in the docs or basic tutorials. I am using Julia 1.4.2 (that is the latest stable release), and, as suggested in the docs/tutorials, the Atom editor with Juno. This is on Ubuntu 18.04.

My minimum reproducible example:

function main()
    b = 300000
    println(b)
    println(b, " asdf")
end

main()

seems to sometimes output, as expected,

300000
300000 asdf

but it often outputs only

300000 asdf

The latter "wrong" output seems to occur most often when Julia is stopped, and I click "Run All", which starts Julia and runs the script. What is happening here? I apologize if this is a trivial beginner mistake. Thank you.

1

There are 1 answers

0
Przemyslaw Szufel On BEST ANSWER

It looks like you are using the Atom IDE.

Unfortunately Atom Juno from time to time is "eating" the first output line of a Julia script - I have seen it few times.

The workaround that seems to work is to force a flush on the standard output cache:

flush(stdout)

This cleans the cache and enforces the communication between Julia REPL and Atom.