Repository: conan-io/conan
Pull request #17819 (2025-02-20 09:04:19)

add warning for local-recipes-idnex used with revisions
Changelog: Feature: Add a warning if a specific revision different than the current one is requested to a ``local-recipes-index`` remote.
Docs: Omit

close https://github.com/conan-io/conan/issues/17814


Patch:
diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py
index ae3acd5ca..4a6a5eca7 100644
--- a/conan/tools/cmake/cmake.py
+++ b/conan/tools/cmake/cmake.py
@@ -185,7 +185,7 @@ class CMake:
 
     def install(self, build_type=None, component=None, cli_args=None, stdout=None, stderr=None):
         """
-        Equivalent to run ``cmake --build . --target=install``
+        Equivalent to running ``cmake --install``
 
         :param component: The specific component to install, if any
         :param build_type: Use it only to override the value defined in the settings.build_type.
diff --git a/conans/client/rest_client_local_recipe_index.py b/conans/client/rest_client_local_recipe_index.py
index 26b398383..7ab87848a 100644
--- a/conans/client/rest_client_local_recipe_index.py
+++ b/conans/client/rest_client_local_recipe_index.py
@@ -138,6 +138,9 @@ class RestApiClientLocalRecipesIndex:
     def get_recipe_revision_reference(self, ref):
         new_ref = self._export_recipe(ref)
         if new_ref != ref:
+            ConanOutput().warning(f"A specific revision '{ref.repr_notime()}' was requested, but it "
+                                  "doesn't match the current available revision in source. The "
+                                  "local-recipes-index can't provide a specific revision")
             raise RecipeNotFoundException(ref)
         return new_ref
 


Test patch:
diff --git a/test/integration/remote/test_local_recipes_index.py b/test/integration/remote/test_local_recipes_index.py
index 12123742c..bbff7cebe 100644
--- a/test/integration/remote/test_local_recipes_index.py
+++ b/test/integration/remote/test_local_recipes_index.py
@@ -332,6 +332,23 @@ class TestErrorsUx:
         c.run("install --requires=zlib/[*] --build missing", assert_error=True)
         assert "NameError: name 'ConanFile' is not defined" in c.out
 
+    def test_require_revision(self):
+        # https://github.com/conan-io/conan/issues/17814
+        folder = temp_folder()
+        recipes_folder = os.path.join(folder, "recipes")
+        zlib_config = textwrap.dedent("""
+           versions:
+             "1.2.11":
+               folder: all
+           """)
+        save_files(recipes_folder,
+                   {"zlib/config.yml": zlib_config,
+                    "zlib/all/conanfile.py": str(GenConanfile("zlib"))})
+        c = TestClient(light=True)
+        c.run(f"remote add local '{folder}'")
+        c.run("install --requires=zlib/1.2.11#rev1", assert_error=True)
+        assert "A specific revision 'zlib/1.2.11#rev1' was requested" in c.out
+
 
 class TestPythonRequires:
     @pytest.fixture(scope="class")
@@ -361,6 +378,7 @@ class TestPythonRequires:
         assert "pyreq/1.0#a0d63ca853edefa33582a24a1bb3c75f - Downloaded (local)" in c.out
         assert "pkg/1.0: Created package" in c.out
 
+
 class TestUserChannel:
     @pytest.fixture(scope="class")
     def c3i_user_channel_folder(self):
@@ -373,8 +391,8 @@ class TestUserChannel:
                   "2.0":
                     folder: other
                 """)
-        pkg = str(GenConanfile("pkg").with_class_attribute("user='myuser'")\
-                                    .with_class_attribute("channel='mychannel'"))
+        pkg = str(GenConanfile("pkg").with_class_attribute("user='myuser'")
+                                     .with_class_attribute("channel='mychannel'"))
         save_files(recipes_folder,
                    {"pkg/config.yml": config,
                     "pkg/all/conanfile.py": pkg,