Skip to content

Commit

Permalink
Verify --channel is not passed without --user (#14443)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbrilRBS authored Aug 8, 2023
1 parent 7e73134 commit a8184cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conan/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions conans/test/integration/command/install/install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit a8184cf

Please sign in to comment.