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

Automatically add compat bounds when adding package in non-shared env #4101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,12 @@ function _resolve(io::IO, env::EnvCache, registries::Vector{Registry.RegistryIns
end
end

# A shared environment lives in the "environments" subdirectory of a depot.
function is_shared_env(project_file::String)
parent_parent = dirname(dirname(project_file))
return basename(parent_parent) == "environments" && dirname(parent_parent) in Base.DEPOT_PATH
end

function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
allow_autoprecomp::Bool=true, preserve::PreserveLevel=default_preserve(), platform::AbstractPlatform=HostPlatform(),
target::Symbol=:deps)
Expand Down Expand Up @@ -1658,8 +1664,8 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
# and ensure they are all downloaded and unpacked as well:
download_artifacts(ctx, platform=platform, julia_version=ctx.julia_version)

# if env is a package add compat entries
if ctx.env.project.name !== nothing && ctx.env.project.uuid !== nothing
# If the environment isn't a shared one add compat entries
if !is_shared_env(ctx.env.project_file)
compat_names = String[]
for pkg in pkgs
haskey(ctx.env.project.compat, pkg.name) && continue
Expand Down
2 changes: 1 addition & 1 deletion src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Add a package to the current project. This package will be available by using th
`import` and `using` keywords in the Julia REPL, and if the current project is
a package, also inside that package.
If the active environment is a package (the Project has both `name` and `uuid` fields) compat entries will be
If the active environment is not a shared one compat entries will be
added automatically with a lower bound of the added version.
To add as a weak dependency (in the `[weakdeps]` field) set the kwarg `target=:weakdeps`.
Expand Down
2 changes: 1 addition & 1 deletion src/REPLMode/command_declarations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ are of the form `@1`, `@1.2` or `@1.2.3`, allowing any version with a prefix
that matches, or ranges thereof, such as `@1.2-3.4.5`. A git revision can be
specified by `#branch` or `#commit`.
If the active environment is a package (the Project has both `name` and `uuid` fields) compat entries will be
If the active environment is not a shared one compat entries will be
added automatically with a lower bound of the added version.
If a local path is used as an argument to `add`, the path needs to be a git repository.
Expand Down
Loading