julia icon indicating copy to clipboard operation
julia copied to clipboard

auto-completion doesn't work correctly in pkg mode

Open matthias314 opened this issue 1 year ago • 2 comments

On master, auto-completion doesn't work for package names in package mode. For example,

(@v1.12) pkg> st
Status `~/.julia/environments/v1.12/Project.toml`
  [0ca39b1e] Chairmarks v1.2.1

(@v1.12) pkg> rm Chair [ now press TAB ]

doesn't complete "Chair" to "Chairmarks". It works on 1.10.4 and 1.11.0-beta2.

Julia Version 1.12.0-DEV.766
Commit 9d8ecaa899d (2024-06-21 17:00 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
  WORD_SIZE: 64
  LLVM: libLLVM-17.0.6 (ORCJIT, sandybridge)
Threads: 1 default, 0 interactive, 1 GC (on 24 virtual cores)

matthias314 avatar Jun 23 '24 14:06 matthias314

It appears that REPLExt is not loaded (as a regular package extension) at startup (even though it should be loaded actually).

julia> using Pkg

julia> Base.get_extension(Pkg, :REPLExt)|>typeof
Nothing

julia> using REPL # Force reinitialization

julia> Base.get_extension(Pkg, :REPLExt)|>typeof
Module

Edit: This could be related to PR #54739 and PR #54891 (see their comments and links) .

kimikage avatar Jun 24 '24 14:06 kimikage

I think it is loaded (how else would there be a Pkg REPL) but it is "hidden". Those linked PRs are indeed relevant.

KristofferC avatar Jun 26 '24 22:06 KristofferC

It works for me if I julia +nightly -ie "using Pkg" but not if I

$ julia +nightly
julia> using Pkg
pkg>

or

$ julia +nightly
julia>]
pkg>

I think it's something to do with the require_stdlib loading mechanics being different. Perhaps part of the REPLExt initialization script assumes a module is classically loaded or something.

IanButterworth avatar Jul 21 '24 17:07 IanButterworth

The problem is that this is failing to find REPLExt when Pkg is loaded via require_stdlib https://github.com/JuliaLang/Pkg.jl/blob/e6880bc9d8a04d95df6e341c76786219a4efc33f/src/REPLMode/command_declarations.jl#L5

IanButterworth avatar Jul 21 '24 19:07 IanButterworth

Ah, makes sense. That is typically forbidden for packages to hook into in that way, as they are only allowed to access packages that they depend upon explicitly

vtjnash avatar Jul 21 '24 20:07 vtjnash

Yeah, I'll try to rework it into something dispatching on a type.

IanButterworth avatar Jul 21 '24 20:07 IanButterworth

Fix: https://github.com/JuliaLang/Pkg.jl/pull/3959

IanButterworth avatar Jul 21 '24 22:07 IanButterworth