Repository: conan-io/conan

Issue:
[question] Editable libs not removable if deleted
### Describe the bug

# Error:
If you remove folders that are in editable mode, there is no easy way to remove them from the editable list anymore.

# workaround: (not tested)
create new conanfile.py in the specific location. 
then it should work again. 

# Expected  behaviour:
using `conan editable remove [folder]` should remove ALL packages in the editable list from that location. 
using `conan editable remove [folder]\conanfilefilename.py` should remove that specific packages in the editable list.
The second suggestion is only for simplification, even through the location could have more files than the default `conanfile.py`. 
The big difference is to the current behaviour, that the folder can be already deleted. 


### How to reproduce it

```shell
conan new something # creating a new lib, replace with proper command 
conan editable add [folder]
rm -r [folder]
conan editable list
conan editable remove [folder] 
# getting Error
conan editable list
# still see the same list
```


Discussion:
Hi @Sickeroni 

Thanks for your question.

> If you remove folders that are in editable mode, there is no easy way to remove them from the editable list anymore.

If you remove the folder containing the editable, you can still remove that editable by reference:
```bash
$ conan editable remove -r=mypkg/0.1
```
Have you tried that?
Hey
Yeah i just tried it and it works!
therefore already thanks! (also because you were fast with helping) 

But now i have a new question.
I would suggest a feature request to have the specific fallback above.  (if directory is removed, still interpret it as it would be) 
It would much more intuitive and userfriendly. 

But I don't think it was never discussed. Can i get some infos about that situation?
(also i qill change the topic to be officially a question) 
> But now i have a new question.
I would suggest a feature request to have the specific fallback above. (if directory is removed, still interpret it as it would be)
It would much more intuitive and userfriendly.

Sounds reasonable, not sure how difficult it is (I think the way it works now is loading the recipe inside the folder, to obtain the reference), lets have a look.
Happens to be trivial, https://github.com/conan-io/conan/pull/16170 planned for next 2.3
Closed by https://github.com/conan-io/conan/pull/16170, will be in 2.3



Patch:
diff --git a/conan/api/subapi/local.py b/conan/api/subapi/local.py
index eaaa3a170b2..88ae8a8fe53 100644
--- a/conan/api/subapi/local.py
+++ b/conan/api/subapi/local.py
@@ -1,5 +1,6 @@
 import os
 
+from conan.api.output import ConanOutput
 from conan.cli import make_abs_path
 from conan.internal.conan_app import ConanApp
 from conans.client.cache.editable import EditablePackages
@@ -60,7 +61,8 @@ def editable_add(self, path, name=None, version=None, user=None, channel=None, c
 
     def editable_remove(self, path=None, requires=None, cwd=None):
         if path:
-            path = self._conan_api.local.get_conanfile_path(path, cwd, py=True)
+            path = make_abs_path(path, cwd)
+            path = os.path.join(path, "conanfile.py")
         return self.editable_packages.remove(path, requires)
 
     def editable_list(self):


Test patch:
diff --git a/conans/test/integration/editable/editable_remove_test.py b/conans/test/integration/editable/editable_remove_test.py
index e28164f683b..837e17601dc 100644
--- a/conans/test/integration/editable/editable_remove_test.py
+++ b/conans/test/integration/editable/editable_remove_test.py
@@ -48,8 +48,9 @@ def test_removed_folder(self,):
         c.save({'pkg/conanfile.py': GenConanfile()})
         c.run('editable add pkg --name=lib --version=version')
         shutil.rmtree(os.path.join(c.current_folder, "pkg"))
-        c.run("editable remove pkg", assert_error=True)
-        c.run("editable remove --refs=lib/version")
+        # https://github.com/conan-io/conan/issues/16164
+        # Making it possible, repeated issue
+        c.run("editable remove pkg")
         assert "Removed editable 'lib/version'" in c.out
         c.run("editable list")
         assert "lib" not in c.out