# Versioninfo not defined in Main

**URL:** <https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969>\
**Category:** General Usage\
**Tags:** eval, versions, versioning, julia-version\
**Created:** [December 18, 2024, 7:07pm UTC](https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969 "2024-12-18T19:07:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![leespen1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leespen1/32/221928_2.png) [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Post date:** [December 18, 2024, 7:07pm UTC](https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969/1 "2024-12-18T19:07:42Z")

</div>

I was debugging some issues I had using `versioninfo()` on an HPC, specifically that I would get the following error:

```julia
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
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:

```julia
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.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [December 18, 2024, 7:12pm UTC](https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969/2 "2024-12-18T19:12:34Z")

</div>

It is a function from `InteractiveUtils`, which is, by default, only loaded if you are in an interactive session:

```bash
%julia -e "using InteractiveUtils; 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: 20 × 12th Gen Intel(R) Core(TM) i7-12700F
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 20 virtual cores)
Environment:
  JULIA_PKG_PRESERVE_TIERED_INSTALLED = true

```

---

<div class="post-metadata">

**Author:** ![leespen1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leespen1/32/221928_2.png) [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Post date:** [December 18, 2024, 7:32pm UTC](https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969/3 "2024-12-18T19:32:54Z")

</div>

That explains it. Thanks!

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 19, 2024, 10:16pm UTC](https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969/4 "2024-12-19T22:16:23Z")

</div>

> [@leespen1](#):
>
> ```julia-auto
> Hint: a global variable of this name may be made accessible by importing InteractiveUtils in the current active module Main
> 
> ```

Did you notice the answer was in the error message you posted?

---

<div class="post-metadata">

**Author:** ![leespen1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leespen1/32/221928_2.png) [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Post date:** [December 20, 2024, 12:22am UTC](https://discourse.julialang.org/t/versioninfo-not-defined-in-main/123969/5 "2024-12-20T00:22:05Z")

</div>

I did not, my bad. I read the first half of the hint, but because I was looking for a missing _function_, not a _variable_, I ignored the rest of the hint as irrelevant.
