I have an old project which uses Julia 1.7.1. I just did:

] activate .

and:

update

Then:

using MyPackage

I get the following error:

ERROR: LoadError: UndefVarError: pkgversion not defined

Any ideas about what’s going on? What to do?

Thank you!

  • While in Julia repl type ] then you you enter pkg mode. Now type st and hit Enter button. Tell us output of (@v1.7) pkg> st

  • Also post here full error that you are getting.

Project MyPackage v0.1.0
      Status `~/Documents/MyPackage/Project.toml`
  [fbb218c0] BSON v0.3.9
  [6e4b80f9] BenchmarkTools v1.6.0
  [e2ed5e7c] Bijections v0.2.2
  [336ed68f] CSV v0.10.15
  [a93c6f00] DataFrames v1.7.0
  [31c24e10] Distributions v0.25.118
  [e30172f5] Documenter v1.11.4
  [35a29f4d] DocumenterTools v0.1.20
  [a98d9a8b] Interpolations v0.15.1
  [4138dd39] JLD v0.13.5
  [16fef848] LiveServer v1.5.0
  [e1d29d7a] Missings v1.2.0
  [3933049c] MultistartOptimization v0.2.3
  [76087f3c] NLopt v1.1.4
  [91a5bcdd] Plots v1.40.13
  [fcd29c91] QuantEcon v0.16.6
  [f2b01f46] Roots v2.2.7
  [2913bbd2] StatsBase v0.34.4
  [f3b207a7] StatsPlots v0.15.7
  [3a884ed6] UnPack v1.0.2
  [9a3f8284] Random
  [10745b16] Statistics

The problem is that pkgversion does not exist in Julia 1.7:

C:\> julia +1.9 -q --startup-file=no                                                                                                                                                       1 06/06/2025 02:08:37 PM
julia> import Pkg; pkgversion
pkgversion (generic function with 1 method)

julia> exit()
C:\> julia +1.8 -q --startup-file=no
julia> import Pkg; pkgversion
ERROR: UndefVarError: pkgversion not defined

so you must have a package (version) which declares compatibility with Julia 1.7 while using functionality that was only introduced in 1.9.

Thanks, how can I find out which package does that?

The stacktrace should tell you?

It mentions several packages but the only one I use in my package directly is QuantEcon I guess this calls other packages, is that possible?

Which options do I have? Can I “un-update” a package? Should I update Julia?

Yes, you can undo in package mode to undo the update.

You can also update Julia, there isn’t really a reason to stay on 1.7 unless you want to stick with the exact package configuration and setup you had when you originally wrote your code for reproduciblity reasons, but given you updated the packages that doesn’t seem to be the case.

FWIW QuantEcon v0.16.6 works fine on Julia 1.7, so your error is likely coming from elsewhere.

2 Likes