cli icon indicating copy to clipboard operation
cli copied to clipboard

Why Is `--workspace-folder` Required. Can we default to $PWD?

Open metaskills opened this issue 3 years ago • 10 comments

I found it odd that this parameter was required when using devcontainer up and was wondering why and if that was intentional. Not sure if it is also required in other commands ( just learning here ) but did want to share it felt odd to do this.

$ devcontainer up --workspace-folder .

metaskills avatar May 21 '22 13:05 metaskills

Even more confusing is the devcontainer build [path] which still require --workspace-folder, seems like a bug, either path or workspace-folder but not both please.

hpe-ykoehler avatar Jun 23 '22 12:06 hpe-ykoehler

Having to type --workspace-folder . all the time is crazy annoying. Please default to $PWD.

alexec avatar Feb 27 '23 15:02 alexec

Having to type --workspace-folder . all the time is crazy annoying. Please default to $PWD.

And add support to specify using an ENV variable as well, DEVCONTAINER_WORKSPACE_FOLDER or whatever.

hpe-ykoehler avatar Feb 27 '23 16:02 hpe-ykoehler

I've created a PR for this.

alexec avatar Feb 27 '23 16:02 alexec

I've created a PR #425, with a basic check if a .devcontainer directory exists in your cwd. I would be pretty easy to add an ENV variable to it, by adding it to the findWorkspaceFolder Function.

@hpe-ykoehler Currently, I'm not convinced if an ENV variable is needed. Do you have a use case for that?

MunsMan avatar Feb 28 '23 14:02 MunsMan

@MunsMan no, but convention is that config option can be controlled by cli argument, env or config file in that order of priority. Agree env may appears less useful, but devcontainer should use a CLI framework that handles all those details (such as Cobra if written in Go) no?

hpe-ykoehler avatar Feb 28 '23 14:02 hpe-ykoehler

I'd suggest not to add the environment variable support unless someone asks.

felipecrs avatar Feb 28 '23 14:02 felipecrs

I added this function to my .zshrc, which does not solve the problem, but reduces the pain:

function dev() {
     devcontainer $1 --workspace-folder . ${@: 2}
 }

Now I can just call dev up or dev exec ls

Maybe it helps someone while the Issue exists.

MunsMan avatar Mar 25 '23 18:03 MunsMan

Hi 👋

Thanks for all the suggestions, and growing interest on this issue. We agree that the cli should have --workspace-folder option as optional and should default to . (ie pwd). We should be able to pick this up soon.

samruddhikhandale avatar Sep 20 '23 15:09 samruddhikhandale