-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Path failure(s) in preferences system for a monorepo #43499
Labels
packages
Package management and loading
Comments
Have you tried 1.6.5? This feels similar to #43361 |
It is similar, but not the same. Here's a MWE: using Pkg, TOML
Pkg.generate("Suite")
suitetoml = TOML.parsefile("Suite/Project.toml")
suiteuuidstr = suitetoml["uuid"]
cd("Suite")
Pkg.activate(".")
Pkg.generate("Config")
Pkg.generate("Use")
Pkg.develop(path="Config")
Pkg.develop(path="Use")
Pkg.activate("./Config")
Pkg.add("Preferences")
Pkg.add("UUIDs")
open("Config/src/Config.jl", "w") do io
write(io, """
module Config
using Preferences
using UUIDs
function setpreferences()
@set_preferences!("prefA" => "SuitePrefs")
# Alternatives:
# set_preferences!(UUID($suiteuuidstr), "prefA" => "SuitePrefs")
end
const prefA = Ref{String}()
function __init__()
p = @load_preference("prefA")
# Alternatives:
# p = load_preference(UUID($suiteuuidstr), "prefA")
p !== nothing && (prefA[] = p)
end
end # module Config
""")
end
Pkg.activate("./Use")
cd("Use")
Pkg.develop(path="../Config")
Pkg.add("Test")
open("src/Use.jl", "w") do io
write(io, """
module Use
using Config
getpref() = Config.prefA[]
end # module Use
""")
end
mkdir("test")
open("test/runtests.jl", "w") do io
write(io,
"""
using Use
using Test
@testset "Use" begin
@test Use.Config.prefA[] == "SuitePrefs"
end
""")
end
cd("..") # back to Suite/
Pkg.activate(".")
Pkg.resolve()
using Config
Config.setpreferences()
Pkg.test("Use") Test fails despite the fact that tim@diva:/tmp/prefbug/Suite$ cat LocalPreferences.toml
[Config]
prefA = "SuitePrefs" |
Is this JuliaLang/Pkg.jl#2500 then? |
Seems like it could be. |
I can work around it with |
This seems to be working now on 1.8, so it was probably a duplicate of JuliaLang/Pkg.jl#2500 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a monorepo with the following structure:
AdmissionSuite has no "real" source code on its own (though to avoid Pkg errors I have to add a dummy
src/AdmissionSuite.jl
with an empty module), its real role is to containProject.toml
andManifest.toml
files with all 3 subdirectoriesdev
ved. This is an attempt to distribute a coherent collection of unregistered mutually-dependent packages (xref https://discourse.julialang.org/t/having-local-packages-in-a-monorepo-depend-on-one-another/50454/4?u=tim.holy).AdmitConfiguration
usesPreferences.jl
and there is aAdmissionSuite/AdmitConfiguration/LocalPreferences.toml
file. For debugging purposes, tobase/loading.jl
I added the following:and then I get the following:
indicating that the preferences are never loaded (
here
is printed at the entry point ofAdmitConfiguration
's attempt to load its own preferences). This is becauseBase.collect_preferences
never receives theproject_toml
of the subdirectory.There appear to be two potential solutions:
AdmissionSuite
rather than the subdir packageSince the configuration written by
AdmitConfiguration
is intended for consumption by all the subpackages, there is a fair amount of sense in the latter. To attempt this, I added aname
anduuid
toAdmissionSuite/Project.toml
, and then toAdmitConfiguration
I addedusing AdmissionSuite
and usedset_preferences!(uuid, ...)
whereuuid
is theuuid
ofAdmissionSuite
. This initially seemed like it might work, butLocalPreferences.jl
file got stored in myv1.6/environments
despite the fact thatAdmissionSuite
was not in the[deps]
of my global environment, and the preferences never ended up getting loaded. So, instead I modified the function that created the preferences file to useand the
__init__
forAdmitConfiguration
to useThis worked (the preferences get loaded with
using AdmitConfiguration
), but it is a narrow path to success and I only got there by reading the source code.The text was updated successfully, but these errors were encountered: