Skip to content

Commit 87100d5

Browse files
committed
Automatically add compat bounds when adding package in non-shared env
1 parent 83e1363 commit 87100d5

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Operations.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,12 @@ function _resolve(io::IO, env::EnvCache, registries::Vector{Registry.RegistryIns
16211621
end
16221622
end
16231623

1624+
# A shared environment lives in the "environments" subdirectory of a depot.
1625+
function is_shared_env(project_file::String)
1626+
parent_parent = dirname(dirname(project_file))
1627+
return parent_parent == "environments" && dirname(parent_parent) in Base.DEPOT_PATH
1628+
end
1629+
16241630
function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
16251631
allow_autoprecomp::Bool=true, preserve::PreserveLevel=default_preserve(), platform::AbstractPlatform=HostPlatform(),
16261632
target::Symbol=:deps)
@@ -1658,8 +1664,8 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
16581664
# and ensure they are all downloaded and unpacked as well:
16591665
download_artifacts(ctx, platform=platform, julia_version=ctx.julia_version)
16601666

1661-
# if env is a package add compat entries
1662-
if ctx.env.project.name !== nothing && ctx.env.project.uuid !== nothing
1667+
# If the environment isn't a shared one add compat entries
1668+
if !is_shared_env(ctx.env.project_file)
16631669
compat_names = String[]
16641670
for pkg in pkgs
16651671
haskey(ctx.env.project.compat, pkg.name) && continue

src/Pkg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Add a package to the current project. This package will be available by using th
123123
`import` and `using` keywords in the Julia REPL, and if the current project is
124124
a package, also inside that package.
125125
126-
If the active environment is a package (the Project has both `name` and `uuid` fields) compat entries will be
126+
If the active environment is not a shared one compat entries will be
127127
added automatically with a lower bound of the added version.
128128
129129
To add as a weak dependency (in the `[weakdeps]` field) set the kwarg `target=:weakdeps`.

src/REPLMode/command_declarations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ are of the form `@1`, `@1.2` or `@1.2.3`, allowing any version with a prefix
121121
that matches, or ranges thereof, such as `@1.2-3.4.5`. A git revision can be
122122
specified by `#branch` or `#commit`.
123123
124-
If the active environment is a package (the Project has both `name` and `uuid` fields) compat entries will be
124+
If the active environment is not a shared one compat entries will be
125125
added automatically with a lower bound of the added version.
126126
127127
If a local path is used as an argument to `add`, the path needs to be a git repository.

0 commit comments

Comments
 (0)