cli icon indicating copy to clipboard operation
cli copied to clipboard

devcontainer exec attempts confuses args depending on order

Open csweichel opened this issue 2 years ago • 3 comments

When running devcontainer exec --workspace-folder . ls everything works as expected. When running devcontainer --workspace-folder . exec ls the devcontainer CLI attempts to run exec in the container. It confuses the args and interprets exec as cmd.

image

Am I correct in assuming that devcontainer --workspace-folder . exec should be a valid way to invoke exec?

csweichel avatar Oct 16 '23 08:10 csweichel

Hi 👋

Am I correct in assuming that devcontainer --workspace-folder . exec should be a valid way to invoke exec?

I don't think that the @devcontainers/cli is configured to be used in ^ way, and that's the reason why it's currently failing.

The @devcontainers/cli expects it to be used as devcontainer <command> [optional args]. See 👇

image

Am I correct in assuming that devcontainer --workspace-folder . exec should be a valid way to invoke exec?

Curious, @csweichel is there a specific reason/interest in expecting it ^ to work in such a way? We can definitely update the CLI based on community interest/feedback, but doesn't seem like this is planned for now.

samruddhikhandale avatar Oct 16 '23 23:10 samruddhikhandale

Curious, @csweichel is there a specific reason/interest in expecting it ^ to work in such a way? We can definitely update the CLI based on community interest/feedback, but doesn't seem like this is planned for now.

Largely past experience with other CLIs where more often than not the order of flags and args does not matter all that much, the occasional ordering of global/command-specific flags notwithstanding.

That said, I'd have expected the CLI to fail with a definite error message when used "incorrectly", rather than it trying to execute something. I was surprised because it seemed like it was working, just not correctly.

csweichel avatar Oct 17 '23 07:10 csweichel

--workspace-folder is needed for most of the subcommands here, and I have been tempted to use a shell alias or wrapper function to provide it automatically. The most obvious way to do that is

alias devcontainer='\devcontainer --workspace-folder=$PROJECT_DIR'

In any event, I think this should generate a clear error and not for devcontainer to try to execute a command named exec in the dev container.

:; devcontainer --workspace-folder=. exec id
OCI runtime exec failed: exec failed: unable to start container process: exec: "exec": executable file not found in $PATH: unknown

groner avatar Dec 08 '23 16:12 groner