Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ArgumentError: Package FooBarExt does not have Bar in its dependencies" when dep in extension (rather than weakdep) #55939

Open
topolarity opened this issue Sep 30, 2024 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior package extensions

Comments

@topolarity
Copy link
Member

This is an interesting one...

$ cat Foo/Project.toml
name = "Foo"
uuid = "9b094d01-e697-4a76-8fe8-871656a862e0"
authors = ["Cody Tapscott <[email protected]>"]
version = "0.1.0"

[deps]
Bar = "ed96e9dd-c367-45ab-9d59-befe4c57f37f"

[weakdeps]
Baz = "5796e38b-8bd2-4f06-8c98-e0a8826bb787"

[extensions]
FooBarExt = "Bar"

The presence of Baz in [weakdeps] seems to "revoke" FooBarExt's rights to using Bar somehow:

$ ./julia --project=testenv -q
julia> using Foo, Bar
Info Given FooBarExt was explicitly requested, output will be shown live
ERROR: LoadError: ArgumentError: Package FooBarExt does not have Bar in its dependencies:
- Note that the following manifests in the load path were resolved with a potentially
  different DEV version of the current version, which may be the cause of the error.
  Try to re-resolve them in the current version, or consider deleting them if that fails:
    /home/topolarity/repos/julia/testenv/Manifest.toml
    /home/topolarity/.julia/environments/v1.12/Manifest.toml
- You may have a partially installed environment. Try `Pkg.instantiate()`
  to ensure all packages in the environment are installed.
- Or, if you have FooBarExt checked out for development and have
  added Bar 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 FooBarExt
Stacktrace:
  [1] macro expansion
    @ ./loading.jl:2262 [inlined]
  [2] macro expansion
    @ ./lock.jl:287 [inlined]
  [3] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2234
  [4] #invoke_in_world#2
    @ ./essentials.jl:1082 [inlined]
  [5] invoke_in_world
    @ ./essentials.jl:1079 [inlined]
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2227
  [7] include
    @ ./Base.jl:582 [inlined]
  [8] 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, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2825
  [9] top-level scope
    @ stdin:5
 [10] eval
    @ ./boot.jl:439 [inlined]
 [11] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:2678
 [12] include_string
    @ ./loading.jl:2688 [inlined]
 [13] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:327
 [14] _start()
    @ Base ./client.jl:558
in expression starting at /home/topolarity/repos/julia/Foo/ext/FooBarExt.jl:1
in expression starting at stdin:5
  ✗ Foo  FooBarExt
Precompiling FooBarExt finished.
  0 dependencies successfully precompiled in 1 seconds. 2 already precompiled.

┌ Error: Error during loading of extension FooBarExt of Foo, use `Base.retry_load_extensions()` to retry.
│   exception =1-element ExceptionStack:
│    The following 1 direct dependency failed to precompile:
│
│    FooBarExt
│
│    Failed to precompile FooBarExt [1cbedc19-d9e5-5698-ba6d-aa629f4ffcbf] to "/home/topolarity/.julia/compiled/v1.12/FooBarExt/jl_UIHQPh".
│    ERROR: LoadError: ArgumentError: Package FooBarExt does not have Bar in its dependencies:- Note that the following manifests in the load path were resolved with a potentially
│      different DEV version of the current version, which may be the cause of the error.
│      Try to re-resolve them in the current version, or consider deleting them if that fails:/home/topolarity/repos/julia/testenv/Manifest.toml
│        /home/topolarity/.julia/environments/v1.12/Manifest.toml
│    - You may have a partially installed environment. Try `Pkg.instantiate()`
│      to ensure all packages in the environment are installed.
│    - Or, if you have FooBarExt checked out for development and have
│      added Bar 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 FooBarExt
│    Stacktrace:
│      [1] macro expansion
│        @ ./loading.jl:2262 [inlined]
│      [2] macro expansion
│        @ ./lock.jl:287 [inlined]
│      [3] __require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:2234
│      [4] #invoke_in_world#2
│        @ ./essentials.jl:1082 [inlined]
│      [5] invoke_in_world
│        @ ./essentials.jl:1079 [inlined]
│      [6] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:2227
│      [7] include
│        @ ./Base.jl:582 [inlined]
│      [8] 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, UInt128}}, source::Nothing)
│        @ Base ./loading.jl:2825
│      [9] top-level scope
│        @ stdin:5
│     [10] eval
│        @ ./boot.jl:439 [inlined]
│     [11] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│        @ Base ./loading.jl:2678
│     [12] include_string
│        @ ./loading.jl:2688 [inlined]
│     [13] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:327
│     [14] _start()
│        @ Base ./client.jl:558in expression starting at /home/topolarity/repos/julia/Foo/ext/FooBarExt.jl:1in expression starting at stdin:
└ @ Base loading.jl:1543

If the [weakdeps] section is removed and I re-resolve everything works fine:

julia +nightly --project=testenv -q
julia> using Foo, Bar
julia>

Happening on latest master (didn't test 1.10 / 1.11, since those don't allow for deps to be valid as an ext trigger like this)

@topolarity topolarity added bug Indicates an unexpected problem or unintended behavior package extensions labels Sep 30, 2024
KristofferC pushed a commit that referenced this issue Oct 18, 2024
@KristofferC
Copy link
Member

I failed to reproduce this. Here is my attempt: 92c4bc9

~/julia/test/project/Extensions/BugDepLookup kc/deps_lookup_bug
❯ ~/julia/julia --project -q               
(BugDepLookup) pkg> st
Project BugDepLookup v0.1.0
Status `~/julia/test/project/Extensions/BugDepLookup/Project.toml`
  [678608ae] SomePackage v0.1.0 `../SomePackage`

julia> using BugDepLookup, SomePackage

julia> Base.get_extension(BugDepLookup, :SomePackageExt)
SomePackageExt

julia> exit()

~/julia/test/project/Extensions/BugDepLookup kc/deps_lookup_bug
❯ ~/julia/julia --project -q
(BugDepLookup) pkg> activate --temp
  Activating new project at `/tmp/jl_JikKPp`

(jl_JikKPp) pkg> dev . ../SomePackage/
   Resolving package versions...
    Updating `/tmp/jl_JikKPp/Project.toml`
  [9b094d01] + BugDepLookup v0.1.0 `../../home/kc/julia/test/project/Extensions/BugDepLookup`
  [678608ae] + SomePackage v0.1.0 `../../home/kc/julia/test/project/Extensions/SomePackage`
    Updating `/tmp/jl_JikKPp/Manifest.toml`
  [9b094d01] + BugDepLookup v0.1.0 `../../home/kc/julia/test/project/Extensions/BugDepLookup`
  [678608ae] + SomePackage v0.1.0 `../../home/kc/julia/test/project/Extensions/SomePackage`

julia> using BugDepLookup, SomePackage

julia> Base.get_extension(BugDepLookup, :SomePackageExt)
SomePackageExt

@KristofferC
Copy link
Member

I think this code has to look in deps as well:

julia/base/loading.jl

Lines 1003 to 1019 in 04259da

if (exts isa String && name == exts) || (exts isa Vector{String} && name in exts)
weakdeps = get(entry, "weakdeps", nothing)::Union{Vector{String}, Dict{String, Any}, Nothing}
if weakdeps !== nothing
if weakdeps isa Vector{String}
found_name = name in weakdeps
break
elseif weakdeps isa Dict{String, Any}
weakdeps = weakdeps::Dict{String, Any}
for (dep, uuid) in weakdeps
uuid::String
if dep === name
return PkgId(UUID(uuid), name)
end
end
end
end
end

That is what failed CI in #56234.

@KristofferC
Copy link
Member

I believe ad1dc39 (that is in #56234) should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior package extensions
Projects
None yet
Development

No branches or pull requests

2 participants