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

Extension not loaded if trigger is a strong dependency [on 1.10] #55723

Open
topolarity opened this issue Sep 10, 2024 · 7 comments
Open

Extension not loaded if trigger is a strong dependency [on 1.10] #55723

topolarity opened this issue Sep 10, 2024 · 7 comments

Comments

@topolarity
Copy link
Member

topolarity commented Sep 10, 2024

# Project.toml
name = "Foo"
uuid = "0a21ebe4-285f-4d3c-b082-40545a858146"
authors = ["Cody Tapscott <topolarity@tapscott.me>"]
version = "0.1.0"

[deps]
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"

[extensions]
ModelingToolkitFooExt = ["ModelingToolkit"]
# ext/ModelingToolkitFooExt/ModelingToolkitFooExt.jl
module ModelingToolkitFooExt

using ModelingToolkit
using Foo

println("loaded ext")

end # ModelingToolkitFooExt

The extension does not load when doing using Foo, ModelingToolkit:

$ julia --project=Foo -q
julia> using Foo, ModelingToolkit

julia> Base.get_extension(Foo, :ModelingToolkitFooExt) === nothing
true
julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × 12th Gen Intel(R) Core(TM) i7-1255U
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

Related: JuliaLang/Pkg.jl#3797 JuliaLang/Pkg.jl#4018

@topolarity topolarity added kind:bug Indicates an unexpected problem or unintended behavior package extensions labels Sep 10, 2024
@topolarity
Copy link
Member Author

If I change [deps] in the Project.toml to [weakdeps] and do a Pkg> resolve and Pkg> instantiate then this works:

julia> using Foo, ModelingToolkit
julia> Base.get_extension(Foo, :ModelingToolkitFooExt)
ModelingToolkitFooExt

@KristofferC
Copy link
Sponsor Member

KristofferC commented Sep 10, 2024

Out or curiosity, what is the use case? Since it is a strong dependency I would thought you would put the code in the package since it will be unconditionally loaded, or?

@KristofferC
Copy link
Sponsor Member

Actually... I thought this would work looking at #54009...

@KristofferC
Copy link
Sponsor Member

Ok, it does work on 1.11, it is just that this feature is not available on 1.10.

@KristofferC KristofferC removed the kind:bug Indicates an unexpected problem or unintended behavior label Sep 10, 2024
@KristofferC KristofferC changed the title Extension not loaded if trigger is a strong dependency Extension not loaded if trigger is a strong dependency [on 1.10] Sep 10, 2024
@topolarity
Copy link
Member Author

Out or curiosity, what is the use case?

Not a very compelling one, but still something I'd expect would work.

I wanted to ] add the extension package so that I could run my tests and I was using --project=. - Basically, I was messing with my environment temporarily as a poor man's version of TestEnv.jl

@KristofferC
Copy link
Sponsor Member

Yeah, that's the use case that was given in #54009 as well.

@topolarity
Copy link
Member Author

Even if the feature is not available on 1.10, I think we ought to fix the KeyError that can happen here: JuliaLang/Pkg.jl#4018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants