Julia 1.8: ChainRules does not have Adapt in its dependencies

I’m working on a codebase I’ve inherited. It runs completely fine in Julia 1.7

However, if I run identical code in Julia 1.8, I get the following error message

ERROR: LoadError: ArgumentError: Package ChainRules does not have Adapt in its dependencies:
- You may have a partially installed environment. Try `Pkg.instantiate()`
  to ensure all packages in the environment are installed.
- Or, if you have ChainRules checked out for development and have
  added Adapt as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with ChainRules
Stacktrace:
 [1] macro expansion
   @ ./loading.jl:1167 [inlined]
 [2] macro expansion
   @ ./lock.jl:223 [inlined]
 [3] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1144
 [4] include
   @ ./Base.jl:419 [inlined]
 [5] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
   @ Base ./loading.jl:1554
 [6] top-level scope
   @ stdin:1
in expression starting at /Users/user/.julia/packages/ChainRules/kZnzE/src/ChainRules.jl:1
in expression starting at stdin:1

I’m not finding anything super helpful online (I think because version 1.8 just came out), and so any pointers in the right direction would be very appreciated!

Can you share the output of Pkg.status()?
( And just to be sure, did you run Pkg.instantiate()? )

I have tried the recommendations given to me by the error message (e.g. Pkg.instantiate()) but I’m getting the same error.

Here is the output of Pkg.status()

Status `~/.julia/environments/v1.8/Project.toml`
  [587475ba] Flux v0.13.5
⌃ [c3e4b0f8] Pluto v0.19.4
Info Packages marked with ⌃ have new versions available

OK, apparently what I needed to update was the dev environment.

But what exactly is this environment?

The dev environment is a local copy of a package, which allows you to change the package locally for yourself. 3. Managing Packages · Pkg.jl
Normally you should not need to use a dev environment if you are just using packages.
There is the pkg> free PackageName command to use the registered version again.

Does the project have a Project.toml file? It looks like you are working in the global environment (@v1.8). Maybe what was missing was to activate the project environment (i.e. in package mode, call pkg> activate .)

By the way, there was recently this post with a nice detailed tutorial on Pkg: jkrumbiegel.com - Pkg.jl and Julia Environments for Beginners

1 Like