Skip to content

Commit 4bcec39

Browse files
authored
Improving error when a workspace super-install defines intermediate packages in the cache (#19013)
1 parent 1cf26c2 commit 4bcec39

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

conan/api/subapi/workspace.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@ def find_folder(ref):
303303
conanfile.workspace_packages_options = {}
304304
for node in deps_graph.nodes[1:]: # Exclude the current root
305305
if node.recipe != RECIPE_EDITABLE:
306+
# sanity check, a pacakge in the cache cannot have dependencies to the workspace
307+
deps_edit = [d.node for d in node.transitive_deps.values()
308+
if d.node.recipe == RECIPE_EDITABLE]
309+
if deps_edit:
310+
raise ConanException(f"Workspace definition error. Package {node} in the "
311+
f"Conan cache has dependencies to packages "
312+
f"in the workspace: {deps_edit}")
306313
result.add_node(node)
307314
continue
308315
conanfile.workspace_packages_options[node.ref] = node.conanfile.options.serialize()

test/integration/workspace/test_workspace.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,21 @@ def root_conanfile(self):
703703
c.run("workspace super-install -of=build -o *:myoption=1")
704704
assert "project Conanfile: Generating with opt dep/0.1:myoption=1!!!!" in c.out
705705

706+
def test_intermediate_non_editable(self):
707+
c = TestClient(light=True)
708+
709+
c.save({"liba/conanfile.py": GenConanfile("liba", "0.1"),
710+
"libb/conanfile.py": GenConanfile("libb", "0.1").with_requires("liba/0.1"),
711+
"libc/conanfile.py": GenConanfile("libc", "0.1").with_requires("libb/0.1")})
712+
713+
c.run("workspace init")
714+
c.run("workspace add liba")
715+
c.run("export libb")
716+
c.run("workspace add libc")
717+
c.run("workspace super-install", assert_error=True)
718+
assert ("Workspace definition error. Package libb/0.1 in the Conan cache "
719+
"has dependencies to packages in the workspace: [liba/0.1]") in c.out
720+
706721

707722
def test_workspace_with_local_recipes_index():
708723
c3i_folder = temp_folder()

0 commit comments

Comments
 (0)