diff --git a/src/Operations.jl b/src/Operations.jl index 6d6bc94558..b25b796e6f 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -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) @@ -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 diff --git a/src/Pkg.jl b/src/Pkg.jl index d6260607dd..99b1c06443 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -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`. diff --git a/src/REPLMode/command_declarations.jl b/src/REPLMode/command_declarations.jl index cb00dfb260..c9115ce0f9 100644 --- a/src/REPLMode/command_declarations.jl +++ b/src/REPLMode/command_declarations.jl @@ -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.