Skip to content

Commit 75ab90f

Browse files
giordanoIanButterworth
authored andcommitted
Automatically add compat bounds when adding package in non-shared env
1 parent 4ef5a5d commit 75ab90f

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
@@ -1725,6 +1725,12 @@ function _resolve(io::IO, env::EnvCache, registries::Vector{Registry.RegistryIns
17251725
end
17261726
end
17271727

1728+
# A shared environment lives in the "environments" subdirectory of a depot.
1729+
function is_shared_env(project_file::String)
1730+
parent_parent = dirname(dirname(project_file))
1731+
return basename(parent_parent) == "environments" && dirname(parent_parent) in Base.DEPOT_PATH
1732+
end
1733+
17281734
function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
17291735
allow_autoprecomp::Bool=true, preserve::PreserveLevel=default_preserve(), platform::AbstractPlatform=HostPlatform(),
17301736
target::Symbol=:deps)
@@ -1761,8 +1767,8 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
17611767
# and ensure they are all downloaded and unpacked as well:
17621768
download_artifacts(ctx, platform=platform, julia_version=ctx.julia_version)
17631769

1764-
# if env is a package add compat entries
1765-
if ctx.env.project.name !== nothing && ctx.env.project.uuid !== nothing
1770+
# If the environment isn't a shared one add compat entries
1771+
if !is_shared_env(ctx.env.project_file)
17661772
compat_names = String[]
17671773
for pkg in pkgs
17681774
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
@@ -144,7 +144,7 @@ Add a package to the current project. This package will be available by using th
144144
`import` and `using` keywords in the Julia REPL, and if the current project is
145145
a package, also inside that package.
146146
147-
If the active environment is a package (the Project has both `name` and `uuid` fields) compat entries will be
147+
If the active environment is not a shared one compat entries will be
148148
added automatically with a lower bound of the added version.
149149
150150
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)