Repository: conan-io/conan

Issue:
Local-recipes-index fails when requested a revision
This is confusing, it just says not existing, but at least a clear warning would be preferred

cc @carobins


Discussion:
https://github.com/conan-io/conan/pull/17819 merged for next 2.13 release



Patch:
diff --git a/conans/client/rest_client_local_recipe_index.py b/conans/client/rest_client_local_recipe_index.py
index 26b398383bd..7ab87848ae4 100644
--- a/conans/client/rest_client_local_recipe_index.py
+++ b/conans/client/rest_client_local_recipe_index.py
@@ -138,6 +138,9 @@ def get_latest_package_reference(self, pref, headers):
     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 12123742cbe..bbff7cebef6 100644
--- a/test/integration/remote/test_local_recipes_index.py
+++ b/test/integration/remote/test_local_recipes_index.py
@@ -332,6 +332,23 @@ class Zlib(ConanFile):
         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 @@ def test_install(self, c3i_pyrequires_folder):
         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 @@ def c3i_user_channel_folder(self):
                   "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,