Repository: conan-io/conan

Issue:
conan search gives AttributeError: 'UserIO' object has no attribute 'warn'
Version: 1.1.1
OS: Linux Ubuntu 14.04 
conda: v4.2.7

Repro steps:
* `conda create -n conan python=2.7`
* `source activate conan`
* `pip install conan`
* `conan search zlib/1.2.11@conan/stable -r=conan-center`

Gives the following python stack:

```
(conan) ~ $ conan search zlib/1.2.11@conan/stable -r=conan-center
Traceback (most recent call last):
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/command.py", line 1131, in run
    method(args[0][1:])
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/command.py", line 814, in search
    outdated=args.outdated)
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/conan_api.py", line 64, in wrapper
    return f(*args, **kwargs)
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/conan_api.py", line 595, in search_packages
    outdated=outdated)
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/cmd/search.py", line 44, in search_packages
    remote = RemoteRegistry(self._client_cache.registry, self._user_io).remote(remote)
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/remote_registry.py", line 95, in remote
    remotes, _ = self._load()
  File "/home/mgodbolt/apps/miniconda/envs/conan/lib/python2.7/site-packages/conans/client/remote_registry.py", line 65, in _load
    self._output.warn("Remotes registry file missing, creating default one in %s"
AttributeError: 'UserIO' object has no attribute 'warn'

ERROR: 'UserIO' object has no attribute 'warn'
```



Discussion:
I just tried using `virtualenv` (v1.11.4) too, same issue.

```
$ conan search zlib/1.2.11@conan/stable -r=conan-center
Traceback (most recent call last):
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/command.py", line 1131, in run
    method(args[0][1:])
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/command.py", line 814, in search
    outdated=args.outdated)
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/conan_api.py", line 64, in wrapper
    return f(*args, **kwargs)
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/conan_api.py", line 595, in search_packages
    outdated=outdated)
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/cmd/search.py", line 44, in search_packages
    remote = RemoteRegistry(self._client_cache.registry, self._user_io).remote(remote)
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/remote_registry.py", line 95, in remote
    remotes, _ = self._load()
  File "/tmp/conan-ve/local/lib/python2.7/site-packages/conans/client/remote_registry.py", line 65, in _load
    self._output.warn("Remotes registry file missing, creating default one in %s"
AttributeError: 'UserIO' object has no attribute 'warn'
```
~~This is very weird. The normal pip install works well, so I guess it might be something related to the conda install. Which is the conan version installed by conda? Can you please post the output of the install procedure? Are you able to install conan in the same machine with normal python (just ``pip install conan``)?
Do you have a link to the conda package for conan? Who created this package? I recall some conan user, but we didn't try it.
Thanks very much for your feedback Matt!~~

Update: reproduced.
Oh, you are totally right. I just reproduced it.

This is a very stupid bug. Just do a:

```bash
$ conan remote list
```
first, as a workaround, or a ``conan search zlib* -r=conan-center``, first, before the failing search command.  You only need to do this once, so conan initializes the remotes.

We will release a fix as soon as possible. Thanks very much for raising this bug!

Resolving patch:
diff --git a/conans/client/cmd/search.py b/conans/client/cmd/search.py
--- a/conans/client/cmd/search.py
+++ b/conans/client/cmd/search.py
@@ -41,7 +41,7 @@ def search_packages(self, reference=None, remote=None, query=None, outdated=Fals
                                    packages properties: "arch=x86 AND os=Windows"
         """
         if remote:
-            remote = RemoteRegistry(self._client_cache.registry, self._user_io).remote(remote)
+            remote = RemoteRegistry(self._client_cache.registry, self._user_io.out).remote(remote)
             packages_props = self._remote_manager.search_packages(remote, reference, query)
             ordered_packages = OrderedDict(sorted(packages_props.items()))
             manifest = self._remote_manager.get_conan_digest(reference, remote)


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
@@ -439,6 +439,15 @@ def search_with_no_local_test(self):
         client.run("search nonexist/1.0@lasote/stable")
         self.assertIn("There are no packages", self.client.user_io.out)
 
+    def search_with_no_registry_test(self):
+        # https://github.com/conan-io/conan/issues/2589
+        client = TestClient()
+        os.remove(os.path.join(client.client_cache.registry))
+        error = client.run("search nonexist/1.0@lasote/stable -r=myremote", ignore_error=True)
+        self.assertTrue(error)
+        self.assertIn("WARN: Remotes registry file missing, creating default one", client.out)
+        self.assertIn("ERROR: No remote 'myremote' defined in remotes", client.out)
+
 
 class SearchOutdatedTest(unittest.TestCase):
     def search_outdated_test(self):