Repository: conan-io/conan

Issue:
conan search fails on macos. Installed with homebrew.
To help us debug your issue please explain:

- [x] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [X] I've specified the Conan version, operating system version and any tool that can be relevant.
- [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

Macos homebrew installed conan

```
$ conan --version
Conan version 1.4.4

$ conan search sdl2
Traceback (most recent call last):
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/client/remote_registry.py", line 66, in _load
    contents = load(self._filename)
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/util/files.py", line 168, in load
    with open(path, 'rb') as handle:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/XXXX/.conan/registry.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/client/command.py", line 1182, in run
    method(args[0][1:])
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/client/command.py", line 861, in search
    all_remotes_search = ("all" not in (r.name for r in remote_registry.remotes) and
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/client/remote_registry.py", line 86, in remotes
    return list(self._remote_dict.values())
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/client/remote_registry.py", line 99, in _remote_dict
    remotes, _ = self._load()
  File "/usr/local/Cellar/conan/1.4.4/libexec/lib/python3.6/site-packages/conans/client/remote_registry.py", line 68, in _load
    self._output.warn("Remotes registry file missing, creating default one in %s"
AttributeError: 'NoneType' object has no attribute 'warn'

ERROR: 'NoneType' object has no attribute 'warn'
```



Discussion:

Resolving patch:
diff --git a/conans/client/command.py b/conans/client/command.py
--- a/conans/client/command.py
+++ b/conans/client/command.py
@@ -10,7 +10,7 @@
 from conans.client.output import Color
 from conans.client.remote_registry import RemoteRegistry
 
-from conans.errors import ConanException
+from conans.errors import ConanException, NoRemoteAvailable
 from conans.model.ref import ConanFileReference
 from conans.util.config_parser import get_bool_from_text
 from conans.util.log import logger
@@ -887,9 +887,11 @@ def search(self, *args):
                 info = self._conan.search_recipes(args.pattern_or_reference, remote=args.remote,
                                                   case_sensitive=args.case_sensitive)
                 # Deprecate 2.0: Dirty check if search is done for all remotes or for remote "all"
-                remote_registry = RemoteRegistry(self._client_cache.registry, None)
-                all_remotes_search = ("all" not in (r.name for r in remote_registry.remotes) and
-                                      args.remote == "all")
+                try:
+                    remote_all = self._conan.get_remote_by_name("all")
+                except NoRemoteAvailable:
+                    remote_all = None
+                all_remotes_search = (remote_all is None and args.remote == "all")
 
                 self._outputer.print_search_references(info["results"], args.pattern_or_reference,
                                                        args.raw, all_remotes_search)


Test patch:
diff --git a/conans/test/command/search_test.py b/conans/test/command/search_test.py
--- a/conans/test/command/search_test.py
+++ b/conans/test/command/search_test.py
@@ -900,6 +900,13 @@ def search_packages_with_reference_not_exported_test(self):
         self.assertTrue(error)
         self.assertIn("ERROR: Recipe not found: my_pkg/1.0@conan/stable", self.client.out)
 
+    def initial_search_without_registry_test(self):
+        client = TestClient()
+        os.remove(client.client_cache.registry)
+        client.run("search my_pkg")
+        self.assertIn("WARN: Remotes registry file missing, creating default one", client.out)
+        self.assertIn("There are no packages matching the 'my_pkg' pattern", client.out)
+
 class SearchOutdatedTest(unittest.TestCase):
     def search_outdated_test(self):
         test_server = TestServer(users={"lasote": "password"})  # exported users and passwords