Repository: conan-io/conan

Issue:
[bug] "conan install . --channel xxx" raises AssertionError
### Environment details

* Conan version: 2.0.9


### Steps to reproduce

Execute `conan install` for an arbitrary consumer recipe with `--channel option`:
```
conan install . --channel xxx
```
It will break with AssertionError. Of course, it doesn't make much sense to specify `--channel` for a consumer recipe but I believe it should be handled correctly. Another problem is that the exception info goes to stdout instead of stderr. So for
```
conan install . --channel xxx --format=json > build.json
```
there is no visible error on the console. Can you also fix that?

### Logs

```
conan install . --channel xxx
...
Traceback (most recent call last):
  File "c:\work\conan-2.0\lib\site-packages\conan\cli\cli.py", line 272, in main
    cli.run(args)
  File "c:\work\conan-2.0\lib\site-packages\conan\cli\cli.py", line 172, in run
    command.run(self._conan_api, args[0][1:])
  File "c:\work\conan-2.0\lib\site-packages\conan\cli\command.py", line 125, in run
    info = self._method(conan_api, parser, *args)
  File "c:\work\conan-2.0\lib\site-packages\conan\cli\commands\install.py", line 65, in install
    deps_graph = conan_api.graph.load_graph_consumer(path, args.name, args.version,
  File "c:\work\conan-2.0\lib\site-packages\conan\api\subapi\graph.py", line 132, in load_graph_consumer
    root_node = self._load_root_consumer_conanfile(path, profile_host, profile_build,
  File "c:\work\conan-2.0\lib\site-packages\conan\api\subapi\graph.py", line 24, in _load_root_consumer_conanfile
    conanfile = app.loader.load_consumer(path,
  File "c:\work\conan-2.0\lib\site-packages\conans\client\loader.py", line 166, in load_consumer
    if str(ref):
  File "c:\work\conan-2.0\lib\site-packages\conans\model\recipe_ref.py", line 62, in __str__
    assert self.user
AssertionError
```

Discussion:

Patch:
diff --git a/conan/cli/args.py b/conan/cli/args.py
index 3313d3280..58399e928 100644
--- a/conan/cli/args.py
+++ b/conan/cli/args.py
@@ -126,6 +126,8 @@ def validate_common_graph_args(args):
     if args.requires and (args.name or args.version or args.user or args.channel):
         raise ConanException("Can't use --name, --version, --user or --channel arguments with "
                              "--requires")
+    if args.channel and not args.user:
+        raise ConanException("Can't specify --channel without --user")
     if not args.path and not args.requires and not args.tool_requires:
         raise ConanException("Please specify a path to a conanfile or a '--requires=<ref>'")
     if args.path and (args.requires or args.tool_requires):


Test patch:
diff --git a/conans/test/integration/command/install/install_test.py b/conans/test/integration/command/install/install_test.py
index cfb48a9ec..1c7af3828 100644
--- a/conans/test/integration/command/install/install_test.py
+++ b/conans/test/integration/command/install/install_test.py
@@ -29,6 +29,9 @@ def test_install_reference_error(client):
     # Test to check the "conan install <path> <reference>" command argument
     client.run("install --requires=pkg/0.1@myuser/testing --user=user --channel=testing", assert_error=True)
     assert "ERROR: Can't use --name, --version, --user or --channel arguments with --requires" in client.out
+    client.save({"conanfile.py": GenConanfile("pkg", "1.0")})
+    client.run("install . --channel=testing", assert_error=True)
+    assert "ERROR: Can't specify --channel without --user" in client.out
 
 
 def test_install_args_error():