I was debugging some issues I had using versioninfo()
on an HPC, specifically that I would get the following error:
ERROR: UndefVarError: `versioninfo` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing InteractiveUtils in the current active module Main
Stacktrace:
[1] top-level scope
@ none:1
But to my surprise, I was able to get the same error on my desktop. If I open a REPL and use versioninfo, everything is fine:
julia> versioninfo()
Julia Version 1.11.2
Commit 5e9a32e7af2 (2024-12-01 20:02 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × AMD Ryzen 5 3600 6-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
But if I try and do it using an eval argument from the command line:
username@my-desktop:~$ julia -e "versioninfo()"
ERROR: UndefVarError: `versioninfo` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing InteractiveUtils in the current active module Main
Stacktrace:
[1] top-level scope
@ none:1
What gives? I imagine that julia -e "code to be evaluated"
should be almost exactly the same as evaluating the same code in a REPL. But maybe there’s something fundamentally different about the two that I don’t understand.