Skip to content
Merged
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
85 changes: 48 additions & 37 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,46 +187,57 @@ for f in (:develop, :add, :rm, :up, :pin, :free, :test, :build, :status, :why, :
end
end

function update_source_if_set(project, pkg)
function update_source_if_set(env, pkg)
project = env.project
source = get(project.sources, pkg.name, nothing)
source === nothing && return
if pkg.repo == GitRepo()
delete!(project.sources, pkg.name)
else
# This should probably not modify the dicts directly...
if pkg.repo.source !== nothing
source["url"] = pkg.repo.source
delete!(source, "path")
if source !== nothing
if pkg.repo == GitRepo()
delete!(project.sources, pkg.name)
else
# This should probably not modify the dicts directly...
if pkg.repo.source !== nothing
source["url"] = pkg.repo.source
delete!(source, "path")
end
if pkg.repo.rev !== nothing
source["rev"] = pkg.repo.rev
delete!(source, "path")
end
if pkg.repo.subdir !== nothing
source["subdir"] = pkg.repo.subdir
end
if pkg.path !== nothing
source["path"] = pkg.path
delete!(source, "url")
delete!(source, "rev")
end
end
if pkg.repo.rev !== nothing
source["rev"] = pkg.repo.rev
delete!(source, "path")
if pkg.subdir !== nothing
source["subdir"] = pkg.subdir
end
if pkg.repo.subdir !== nothing
source["subdir"] = pkg.repo.subdir
path, repo = get_path_repo(project, pkg.name)
if path !== nothing
pkg.path = path
end
if pkg.path !== nothing
source["path"] = pkg.path
delete!(source, "url")
delete!(source, "rev")
if repo.source !== nothing
pkg.repo.source = repo.source
end
if repo.rev !== nothing
pkg.repo.rev = repo.rev
end
if repo.subdir !== nothing
pkg.repo.subdir = repo.subdir
end
end
if pkg.subdir !== nothing
source["subdir"] = pkg.subdir
end
path, repo = get_path_repo(project, pkg.name)
if path !== nothing
pkg.path = path
end
if repo.source !== nothing
pkg.repo.source = repo.source
end
if repo.rev !== nothing
pkg.repo.rev = repo.rev
end
if repo.subdir !== nothing
pkg.repo.subdir = repo.subdir

# Packages in manifest should have their paths set to the path in the manifest
for (path, wproj) in env.workspace
if wproj.uuid == pkg.uuid
pkg.path = Types.relative_project_path(env.manifest_file, dirname(path))
break
end
end
return
end

function develop(ctx::Context, pkgs::Vector{PackageSpec}; shared::Bool=true,
Expand Down Expand Up @@ -268,7 +279,7 @@ function develop(ctx::Context, pkgs::Vector{PackageSpec}; shared::Bool=true,
if length(findall(x -> x.uuid == pkg.uuid, pkgs)) > 1
pkgerror("it is invalid to specify multiple packages with the same UUID: $(err_rep(pkg))")
end
update_source_if_set(ctx.env.project, pkg)
update_source_if_set(ctx.env, pkg)
end

Operations.develop(ctx, pkgs, new_git; preserve=preserve, platform=platform)
Expand Down Expand Up @@ -322,7 +333,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}; preserve::PreserveLevel=Op
if length(findall(x -> x.uuid == pkg.uuid, pkgs)) > 1
pkgerror("it is invalid to specify multiple packages with the same UUID: $(err_rep(pkg))")
end
update_source_if_set(ctx.env.project, pkg)
update_source_if_set(ctx.env, pkg)
end

Operations.add(ctx, pkgs, new_git; allow_autoprecomp, preserve, platform, target)
Expand Down Expand Up @@ -401,7 +412,7 @@ function up(ctx::Context, pkgs::Vector{PackageSpec};
ensure_resolved(ctx, ctx.env.manifest, pkgs)
end
for pkg in pkgs
update_source_if_set(ctx.env.project, pkg)
update_source_if_set(ctx.env, pkg)
end
Operations.up(ctx, pkgs, level; skip_writing_project, preserve)
return
Expand Down Expand Up @@ -440,7 +451,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec}; all_pkgs::Bool=false, kwar
pkgerror("pinning a package requires a single version, not a versionrange")
end
end
update_source_if_set(ctx.env.project, pkg)
update_source_if_set(ctx.env, pkg)
end

project_deps_resolve!(ctx.env, pkgs)
Expand Down
5 changes: 5 additions & 0 deletions test/test_packages/WorkspacePathResolution/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
projects = [
"SubProjectA",
"SubProjectB",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name = "SubProjectA"
uuid = "87654321-4321-4321-4321-210987654321"
version = "0.1.0"

[deps]
SubProjectB = "12345678-1234-1234-1234-123456789012"

[sources]
SubProjectB = {path = "SubProjectB"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module SubProjectA

using SubProjectB

greet() = "Hello from SubProjectA! " * SubProjectB.greet()

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "SubProjectB"
uuid = "12345678-1234-1234-1234-123456789012"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module SubProjectB

greet() = "Hello from SubProjectB!"

end
15 changes: 15 additions & 0 deletions test/workspaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,19 @@ end
end
end

@testset "workspace path resolution issue #4222" begin
mktempdir() do dir
path = copy_test_package(dir, "WorkspacePathResolution")
cd(path) do
with_current_env() do
# First resolve SubProjectB (non-root project) without existing Manifest
Pkg.activate("SubProjectB")
@test !isfile("Manifest.toml")
# Should be able to find SubProjectA and succeed
Pkg.update()
end
end
end
end

end # module