Repository: conan-io/conan

Issue:
Conan install exits when a remote is not available
My Conan config has multiple remotes defined:
* LocalRemoteA
* LocalRemoteB

Most of my packages are on LocalRemoteA, but some are on LocalRemoteB. Usually this isn't an issue, as conan install searches through them in the order they are defined.

Yesterday LocalRemoteA wasn't reachable for some time due to maintenance. We found that if a remote isn't reachable Conan exits with an error instead of continuing to search on the next remote.

Not sure what the expected behaviour should be, as it could be an error when a remote is defined that isn't reachable. Simply falling back to the next remote could lead to older packages being used (perhaps LocalRemoteB is just an old backup remote) without the user really noticing.

In my case it would be better to continue searching for the dependency on the next remote instead of exiting, as the desired package was uploaded onto LocalRemoteB anyways.

* Happened on Windows 7 Prof, not sure if this is important
* Happens with Conan 1.18.4
Conan install exits when a remote is not available
My Conan config has multiple remotes defined:
* LocalRemoteA
* LocalRemoteB

Most of my packages are on LocalRemoteA, but some are on LocalRemoteB. Usually this isn't an issue, as conan install searches through them in the order they are defined.

Yesterday LocalRemoteA wasn't reachable for some time due to maintenance. We found that if a remote isn't reachable Conan exits with an error instead of continuing to search on the next remote.

Not sure what the expected behaviour should be, as it could be an error when a remote is defined that isn't reachable. Simply falling back to the next remote could lead to older packages being used (perhaps LocalRemoteB is just an old backup remote) without the user really noticing.

In my case it would be better to continue searching for the dependency on the next remote instead of exiting, as the desired package was uploaded onto LocalRemoteB anyways.

* Happened on Windows 7 Prof, not sure if this is important
* Happens with Conan 1.18.4


Discussion:
Hi, @monsdar. It is expected behavior, we decided not to ignore failing remotes.

And, as we know that _removing_ and _adding_ a remote can be error-prone (typos in the URL) and tedious, we have added to `1.19` a new feature to allow **enabling and disabling remotes**: https://github.com/conan-io/conan/pull/5623

Ok, this would help us very well. Not sure if putting in a nicer error message (that perhaops even says that Conan is exiting intentionally now) would help a bit.

Close here?
> Ok, this would help us very well. Not sure if putting in a nicer error message (that perhaops even says that Conan is exiting intentionally now) would help a bit.

The current error message looks like:

> boost/1.19: Not found in local cache, looking in remotes...
boost/1.19: Trying with 'artifactory'...
ERROR: HTTPConnectionPool(host='localhost', port=8081): Max retries exceeded with url: /artifactory/api/conan/conan-local/v1/ping (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x047A7350>: Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it',))

> Unable to connect to artifactory=http://localhost:8081/artifactory/api/conan/conan-local

We decided to keep the whole network error message, because it helps to diagnose what is failing. What would be the recommended error message instead of "Unable to connect to xxxxx"?
What happened in my case was to see the network error and immediately thinking "shouldn't Conan continue with the next Remote??" - then opening this issue to ask for clarification.

As laid out it is intended by Conan to exit after encountering something like that, so after showing the network error I'd tell the user:

> Looks like installing is not possible, as one of your configured remotes is not available right now. This is unexpected and should not happen. If you need this remote to be online please ask an Administrator what happened. If this remote is not needed you can deactivate it with conan remote deactivate. Conan will now exit.

I'm not the best when it comes to writing these type of things, but I hope you got the idea?
I am fine with trying to improve the error message. Should be something shorter than that, but it makes sense to try to clarify things
Hi, @monsdar. It is expected behavior, we decided not to ignore failing remotes.

And, as we know that _removing_ and _adding_ a remote can be error-prone (typos in the URL) and tedious, we have added to `1.19` a new feature to allow **enabling and disabling remotes**: https://github.com/conan-io/conan/pull/5623

Ok, this would help us very well. Not sure if putting in a nicer error message (that perhaops even says that Conan is exiting intentionally now) would help a bit.

Close here?
> Ok, this would help us very well. Not sure if putting in a nicer error message (that perhaops even says that Conan is exiting intentionally now) would help a bit.

The current error message looks like:

> boost/1.19: Not found in local cache, looking in remotes...
boost/1.19: Trying with 'artifactory'...
ERROR: HTTPConnectionPool(host='localhost', port=8081): Max retries exceeded with url: /artifactory/api/conan/conan-local/v1/ping (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x047A7350>: Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it',))

> Unable to connect to artifactory=http://localhost:8081/artifactory/api/conan/conan-local

We decided to keep the whole network error message, because it helps to diagnose what is failing. What would be the recommended error message instead of "Unable to connect to xxxxx"?
What happened in my case was to see the network error and immediately thinking "shouldn't Conan continue with the next Remote??" - then opening this issue to ask for clarification.

As laid out it is intended by Conan to exit after encountering something like that, so after showing the network error I'd tell the user:

> Looks like installing is not possible, as one of your configured remotes is not available right now. This is unexpected and should not happen. If you need this remote to be online please ask an Administrator what happened. If this remote is not needed you can deactivate it with conan remote deactivate. Conan will now exit.

I'm not the best when it comes to writing these type of things, but I hope you got the idea?
I am fine with trying to improve the error message. Should be something shorter than that, but it makes sense to try to clarify things

Resolving patch:
diff --git a/conans/client/remote_manager.py b/conans/client/remote_manager.py
--- a/conans/client/remote_manager.py
+++ b/conans/client/remote_manager.py
@@ -244,8 +244,11 @@ def _call_remote(self, remote, method, *argc, **argv):
         try:
             return getattr(self._auth_manager, method)(*argc, **argv)
         except ConnectionError as exc:
-            raise ConanConnectionError("%s\n\nUnable to connect to %s=%s"
-                                       % (str(exc), remote.name, remote.url))
+            raise ConanConnectionError(("%s\n\nUnable to connect to %s=%s\n" +
+                                        "1. Make sure the remote is reachable or,\n" +
+                                        "2. Disable it by using conan remote disable,\n" +
+                                        "Then try again."
+                                        ) % (str(exc), remote.name, remote.url))
         except ConanException as exc:
             exc.remote = remote
             raise


Test patch: