# Varinfo() not working on script

**URL:** <https://discourse.julialang.org/t/varinfo-not-working-on-script/129365>\
**Category:** New to Julia\
**Created:** [May 27, 2025, 7:15am UTC](https://discourse.julialang.org/t/varinfo-not-working-on-script/129365 "2025-05-27T07:15:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefaniecg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefaniecg/32/204815_2.png) [@stefaniecg](https://discourse.julialang.org/u/stefaniecg)\
**Post date:** [May 27, 2025, 7:15am UTC](https://discourse.julialang.org/t/varinfo-not-working-on-script/129365/1 "2025-05-27T07:15:56Z")

</div>

I run the below script via command line: `julia script.jl`.

```julia
# file name: script.jl
a = 1
b = 2
c = a + b
varinfo()

```

My problem is that the varinfo() does not run in terminal, i get the following error:  
`ERROR: LoadError: UndefVarError: 'varinfo' not defined`.

How can i show at the end of my run the status of all variables in the script when i run the script in commandline?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [May 27, 2025, 7:28am UTC](https://discourse.julialang.org/t/varinfo-not-working-on-script/129365/2 "2025-05-27T07:28:16Z")

</div>

This function and some others are primarily intended for interactive use and are loaded by default in an interactive session. To see where it comes from you can do this.

```julia
julia> @which varinfo
InteractiveUtils

```

You can load `InteractiveUtils` explicitly in your script to make `varinfo` available.

```julia
using InteractiveUtils
a = 1
b = 2
c = a + b
println(varinfo())

```

---

<div class="post-metadata">

**Author:** ![stefaniecg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefaniecg/32/204815_2.png) [@stefaniecg](https://discourse.julialang.org/u/stefaniecg)\
**Post date:** [May 27, 2025, 7:43am UTC](https://discourse.julialang.org/t/varinfo-not-working-on-script/129365/3 "2025-05-27T07:43:33Z")

</div>

Thank you so much @GunnarFarneback

An extra question.  
how can i print all the variables and their value ?  
`varinfo()` only prints the variables name, size, and type.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [May 27, 2025, 8:48am UTC](https://discourse.julialang.org/t/varinfo-not-working-on-script/129365/4 "2025-05-27T08:48:43Z")

</div>

I don’t know about anything that does that out of the box but you can do something yourself like

```julia
for var in names(Main)
    value = getfield(Main, var)
    if value isa Number
        println(var, " = ", value)
    end
end

```

---

<div class="post-metadata">

**Author:** ![stefaniecg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefaniecg/32/204815_2.png) [@stefaniecg](https://discourse.julialang.org/u/stefaniecg)\
**Post date:** [May 27, 2025, 8:58am UTC](https://discourse.julialang.org/t/varinfo-not-working-on-script/129365/5 "2025-05-27T08:58:26Z")

</div>

thank you so much ! 😊
