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

Pkg.test() drops Preferences #2500

Closed
staticfloat opened this issue Apr 9, 2021 · 3 comments · Fixed by #2920
Closed

Pkg.test() drops Preferences #2500

staticfloat opened this issue Apr 9, 2021 · 3 comments · Fixed by #2920

Comments

@staticfloat
Copy link
Member

While attempting to move FFTW over to using Preferences instead of environment variables/mutating its own state to record which backend is currently in use, I have discovered that Pkg generates a new project when running tests, and that new project drops unknown metadata. I believe the culprit is this section:

Pkg.jl/src/Operations.jl

Lines 1516 to 1534 in 0fe89b1

# collect relevant info from source
source_env = EnvCache(projectfile_path(source_path))
# collect regular dependencies
test_project.deps = source_env.project.deps
# collect test dependencies
for name in get(source_env.project.targets, target, String[])
uuid = get(source_env.project.extras, name, nothing)
if uuid === nothing
pkgerror("`$name` declared as a `$target` dependency, but no such entry in `extras`")
end
test_project.deps[name] = uuid
end
# collect compat entries
for (name, uuid) in test_project.deps
compat = get_compat_str(source_env.project, name)
compat === nothing && continue
set_compat(test_project, name, compat)
end
return test_project

Since users (and other packages) are storing pieces of information inside of Project.toml files, I think we need to preserve as much information in the Project.toml as possible.

For preferences in particular, we also need to copy any LocalPreferences.toml files to the temporary directory where the project is stored as well. I am currently working around this by generating an explicit test/Project.toml, but this is obviously sub-optimal.

@simonbyrne
Copy link
Contributor

Same for Pkg.build.

@vchuravy
Copy link
Member

vchuravy commented Jan 4, 2022

We might want to do this for the sandbox used for .pkg/select_artifacts.jl as well.

@vchuravy
Copy link
Member

vchuravy commented Jan 5, 2022

It seems like adding the preferences to the test/Project.toml instead of test/LocalPreferences.toml works on 1.7

[deps]
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Foo = "48898bec-3adb-11e9-02a6-a164ba74aeae"

[preferences]
Foo.tree = "birch"

timholy added a commit to timholy/AdmissionSuite.jl that referenced this issue Feb 15, 2022
JuliaLang/Pkg.jl#2500 was fixed for Julia
1.8, so revert the workaround on those versions.

Also removes a test which didn't really make sense given that we
adopted `merge!` semantics for preferences.
maleadt added a commit to maleadt/LLVM.jl that referenced this issue Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants