Help building Julia Pkg.jl repo locally to work on an issue

I was working on this issue #42687. As a part of this I need to setup this repo locally. But upon following the instruction given in the repo, I followed all the steps. But I’m getting this error upon executing import Pkg in the repl opened in the directory where I cloned the repo:

julia> import Pkg
[ Info: Precompiling Pkg [54cfe95a-1eb2-52ea-b672-e2afdf69b78f]
ERROR: InitError: UndefVarError: install_packages_hooks not defined
Stacktrace:
 [1] __init__()
   @ Pkg C:\Users\chand\Documents\Pkg-source\Pkg.jl\src\Pkg.jl:626
 [2] _include_from_serialized(path::String, depmods::Vector{Any})
   @ Base .\loading.jl:696
 [3] _require_from_serialized(path::String)
   @ Base .\loading.jl:749
 [4] _require(pkg::Base.PkgId)
   @ Base .\loading.jl:1053
 [5] require(uuidkey::Base.PkgId)
   @ Base .\loading.jl:936
 [6] require(into::Module, mod::Symbol)
   @ Base .\loading.jl:923
during initialization of module Pkg

But when I run the same import Pkg again, It ran without errors. Is this something to worry about? Or can I continue with running ìmport Pkg again and proceed?

2 Likes

REPL.install_packages_hooks was added in Enable REPL to offer to install missing packages if install hooks are provided by IanButterworth · Pull Request #39026 · JuliaLang/julia · GitHub and requires at least Julia 1.7. Are you trying to use a development version of Pkg.jl on Julia 1.6? Quite possibly the easiest fix would be to build Julia itself from source:

  • clone the Julia repository
  • make DEPS_GIT=Pkg

There’s a little more detail in a paragraph on the Pkg.jl README: GitHub - JuliaLang/Pkg.jl: Pkg - Package manager for the Julia programming language. You would most readily do your development in stdlib/Pkg rather than a separate checkout of Pkg.jl.

2 Likes

One other thing: that issue may be slightly trickier than I initially realized because it may not be very easy to use Revise, which will make your workflow less efficient. Nevertheless I think it might be possible, based on this test:

$ julia -i -e "using Revise, Pkg; Revise.track(Pkg); revise(); println(Base.active_repl)"
ERROR: UndefVarError: active_repl not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:26
 [2] top-level scope
   @ none:1

The fact that it errors suggests that those commands run before the REPL is initialized. This is good news. So just delete that last part about Base.active_repl and see whether you can edit the code in Pkg and have your changes take effect without having to rebuild Julia each time you change something.

1 Like

Yeah, I have built the Julia locally by specifying make DEPS_GIT=Pkg, and used Revise.
But the changes I’m making to the files inside stdlib/Pkg/ aren’t getting reflected in the julia prompt.
But I’ve seen this and tried Revise.track(Base) this works fine with the changes I’ve done are getting reflected.
I can’t understand why changes to stdlib/Pkg are not getting detected?

I cloned the Pkg.jl package and added the ./julia executable to my path (So that I can do julia --project as mentioned here). Now, I tried changing some content in Pkg.REPLMode.help (Just to check if my changes are getting reflected). And I changed the UUID in project.toml file. I did using Pkg in Julia prompt. Then I tried Pkg.REPLMode.help, but I can’t see my changes. Instead when I did Pkg.REPLMode.gen_help(), now I see my changes. I’m asking this out of curiosity and I guess this is loosely related to the discussion. Why is this happening? Is there something wrong I’m doing here?

I haven’t had time to look in detail, but anything that happens once upon startup is kind of a special case as it is order dependent.

1 Like

No problem, I figured it out and working on the issue. I think I can soon solve it.

1 Like