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

**URL:** <https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021>\
**Category:** Internals & Design\
**Created:** [October 19, 2021, 10:04am UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021 "2021-10-19T10:04:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chandu-4444](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chandu-4444/32/29923_2.png) [@Chandu-4444](https://discourse.julialang.org/u/Chandu-4444)\
**Post date:** [October 19, 2021, 10:04am UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/1 "2021-10-19T10:04:18Z")

</div>

I was working on this issue [#42687](https://github.com/JuliaLang/julia/issues/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
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?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 19, 2021, 12:06pm UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/2 "2021-10-19T12:06:16Z")

</div>

`REPL.install_packages_hooks` was added in [https://github.com/JuliaLang/julia/pull/39026](https://github.com/JuliaLang/julia/pull/39026) 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: [https://github.com/JuliaLang/Pkg.jl](https://github.com/JuliaLang/Pkg.jl). You would most readily do your development in `stdlib/Pkg` rather than a separate checkout of Pkg.jl.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 19, 2021, 2:30pm UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/3 "2021-10-19T14:30:05Z")

</div>

One other thing: that issue may be slightly trickier than I initially realized because it may not be very easy to use [Revise](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#modifying-base-more-efficiently-with-revisejl), which will make your workflow less efficient. Nevertheless I think it might be possible, based on this test:

```nohighlight
$ 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.

---

<div class="post-metadata">

**Author:** ![Chandu-4444](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chandu-4444/32/29923_2.png) [@Chandu-4444](https://discourse.julialang.org/u/Chandu-4444)\
**Post date:** [October 19, 2021, 3:36pm UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/4 "2021-10-19T15:36:39Z")

</div>

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](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#modifying-base-more-efficiently-with-revisejl) 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?

---

<div class="post-metadata">

**Author:** ![Chandu-4444](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chandu-4444/32/29923_2.png) [@Chandu-4444](https://discourse.julialang.org/u/Chandu-4444)\
**Post date:** [October 20, 2021, 6:28am UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/5 "2021-10-20T06:28:21Z")

</div>

I cloned the Pkg.jl package and added the `./julia` executable to my path (So that I can do `julia --project` as mentioned [here](https://github.com/JuliaLang/Pkg.jl#using-the-development-version-of-pkgjl)). 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?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 21, 2021, 12:26pm UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/6 "2021-10-21T12:26:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chandu-4444](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chandu-4444/32/29923_2.png) [@Chandu-4444](https://discourse.julialang.org/u/Chandu-4444)\
**Post date:** [October 21, 2021, 12:31pm UTC](https://discourse.julialang.org/t/help-building-julia-pkg-jl-repo-locally-to-work-on-an-issue/70021/7 "2021-10-21T12:31:01Z")

</div>

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