Skip to content

Conversation

@dev0x13
Copy link
Contributor

@dev0x13 dev0x13 commented Oct 18, 2025

Changelog: Omit
Docs: Omit

This PR fixes the seemingly (according to docs) incorrect requirement for ref field presence in the conanws.yml file. Without the fix conan workspace super-install fails with KeyError: 'ref' if any of listed packages lacks ref specification.

It seems that the behaviour was accidentally broken in this commit, so I also removed ref specification from one of the packages in the workspaces template file, so that it's covered by the existing tests.

@CLAassistant
Copy link

CLAassistant commented Oct 18, 2025

CLA assistant check
All committers have signed the CLA.

@memsharded memsharded self-assigned this Oct 19, 2025
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for raising this issue and contributing the fix @dev0x13!

I have checked the PR, and it seems that it is possible to better leverage the existing packages() to compute the package reference, instead of having to re-implement the logic here.

I am trying these changes and it seems works fine:

diff --git a/conan/api/subapi/workspace.py b/conan/api/subapi/workspace.py                                
index 41ce0d670..8946d787c 100644                                                                         
--- a/conan/api/subapi/workspace.py                                                                       
+++ b/conan/api/subapi/workspace.py                                                                       
@@ -263,10 +263,10 @@ class WorkspaceAPI:                                                                 
                                                                                                          
     def super_build_graph(self, deps_graph, profile_host, profile_build):                                
         order = []                                                                                       
-        packages = self._ws.packages()                                                                   
+        packages = self.packages()                                                                       
                                                                                                          
         def find_folder(ref):                                                                            
-            return next(p["path"] for p in packages if RecipeReference.loads(p["ref"]) == ref)           
+            return next(p["path"] for ref, p in packages.items() if ref == ref)                          
                                                                                                          
         for level in deps_graph.by_levels():                                                             
             items = [item for item in level if item.recipe == "Editable"]                                
diff --git a/test/integration/workspace/test_workspace.py b/test/integration/workspace/test_workspace.py  
index 271a3a5f9..00911c41b 100644                                                                         
--- a/test/integration/workspace/test_workspace.py                                                        
+++ b/test/integration/workspace/test_workspace.py                                                        
@@ -1117,6 +1117,11 @@ def test_workspace_defining_only_paths():                                          
     assert "liba/0.1@myuser/mychannel - Editable" in c.out                                               
     assert "libb/0.1 - Editable" in c.out                                                                
                                                                                                          
+    c.run("workspace super-install")                                                                     
+    assert "app1/0.1 - Editable" in c.out                                                                
+    assert "liba/0.1@myuser/mychannel - Editable" in c.out                                               
+    assert "libb/0.1 - Editable" in c.out                                                                
+                                                                                                         

I also think it would be better not to change the new workspace template, removing one of the references there, as it will leave it a bit asymetrical. So I have added a conan workspace super-install call to the test that defines the workspace only with paths, to check it works.

@memsharded memsharded added this to the 2.22.0 milestone Oct 19, 2025
@dev0x13
Copy link
Contributor Author

dev0x13 commented Oct 19, 2025

@memsharded Thanks for review and for the comments! I made the requested changes with a slight fix to the proposed find_folder implementation.

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, many thanks!!

@dev0x13 dev0x13 requested a review from memsharded October 22, 2025 06:53
@memsharded memsharded merged commit 11a68f5 into conan-io:develop2 Oct 22, 2025
16 checks passed
@memsharded
Copy link
Member

Merged! It will be in next 2.22, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants