Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
metaskills opened this issue May 21, 2022 · 10 comments · May be fixed by #425
Open

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

metaskills opened this issue May 21, 2022 · 10 comments · May be fixed by #425
Assignees
Labels
feature-request New feature or request
Milestone

Comments

@metaskills
Copy link

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 metaskills changed the title Why Is --workspace-folder Required or Default to $PWD? Why Is --workspace-folder Required. Can we default to $PWD? May 21, 2022
@chrmarti chrmarti self-assigned this May 23, 2022
@chrmarti chrmarti added the feature-request New feature or request label May 23, 2022
@chrmarti chrmarti added this to the Backlog milestone May 23, 2022
@hpe-ykoehler
Copy link

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.

@alexec
Copy link

alexec commented Feb 27, 2023

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

@hpe-ykoehler
Copy link

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.

@alexec
Copy link

alexec commented Feb 27, 2023

I've created a PR for this.

@MunsMan MunsMan linked a pull request Feb 27, 2023 that will close this issue
@MunsMan
Copy link

MunsMan commented Feb 28, 2023

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?

@hpe-ykoehler
Copy link

@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?

@felipecrs
Copy link

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

@MunsMan
Copy link

MunsMan commented Mar 25, 2023

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.

@samruddhikhandale
Copy link
Member

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.

@shish
Copy link

shish commented Oct 9, 2024

We should be able to pick this up soon

Polite ping :)

I see three people have attempted to do this in a smart way (recursing up parent directories looking for either .devcontainer or .devcontainer.json) and all ended up either abandoned or in review hell; perhaps it's worth doing the dumb and simple thing of just "set the default to $PWD" in order to satisfy the most common use-case, and the fancy recursion can be added as a backwards compatible enhancement later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment