Skip to content

Conversation

@Mathiyarasy
Copy link

@Mathiyarasy Mathiyarasy commented Nov 12, 2025

Fixes: #1069

Issue summary:

This PR enhances the user experience by automatically defaulting the [--workspace-folder] parameter to the current working directory when it is not explicitly specified. The following DevContainer CLI commands will now use the current working directory as the default workspace folder if [--workspace-folder] is omitted:

  • devcontainer build
  • devcontainer up
  • devcontainer exec
  • devcontainer templates apply
  • devcontainer features resolve-dependencies
  • devcontainer upgrade
  • devcontainer outdated
  • devcontainer read-configuration
  • devcontainer run-user-commands

Test cases is implemented for all these commands

@Mathiyarasy Mathiyarasy marked this pull request as ready for review November 12, 2025 13:43
@Mathiyarasy Mathiyarasy requested a review from a team as a code owner November 12, 2025 13:43
@Mathiyarasy Mathiyarasy marked this pull request as draft November 17, 2025 09:51
@Mathiyarasy Mathiyarasy marked this pull request as ready for review November 24, 2025 08:36
@Mathiyarasy Mathiyarasy changed the title For Exec Defaults workspace folder to current directory if not specified DevContainer commands now default the workspace folder to the current directory if not specified. Nov 24, 2025
Copy link
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks! Left a few comments.

'container-data-folder': { type: 'string', description: 'Container data folder where user data inside the container will be stored.' },
'container-system-data-folder': { type: 'string', description: 'Container system data folder where system data inside the container will be stored.' },
'workspace-folder': { type: 'string', description: 'Workspace folder path. The devcontainer.json will be looked up relative to this path.' },
'workspace-folder': { type: 'string', description: 'Workspace folder path. The devcontainer.json will be looked up relative to this path. If not provided, defaults to the current directory.' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention --container-id and --id-label like in the descriptions of the other commands.

"name": "@devcontainers/cli",
"description": "Dev Containers CLI",
"version": "0.80.2",
"version": "0.80.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it 0.81.0 and list the improvement in the changelog.

.options({
'log-level': { choices: ['error' as 'error', 'info' as 'info', 'debug' as 'debug', 'trace' as 'trace'], default: 'error' as 'error', description: 'Log level.' },
'workspace-folder': { type: 'string', description: 'Workspace folder to use for the configuration.', demandOption: true },
'workspace-folder': { type: 'string', description: 'Workspace folder to use for the configuration.' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention using the current folder when not provided like in the other descriptions.

return y
.options({
'workspace-folder': { type: 'string', alias: 'w', demandOption: true, default: '.', description: 'Target workspace folder to apply Template' },
'workspace-folder': { type: 'string', alias: 'w', default: '.', description: 'Target workspace folder to apply Template' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention the default like in the other descriptions. Maybe omit default: '.', though I'm not sure that shows anywhere (like in the help text).

const absoluteCliPath = `npx --prefix ${absoluteTmpPath} devcontainer`;

// First check if the config file exists
const configExists = require('fs').existsSync('.devcontainer/devcontainer.json') ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use import at the top instead of require.

jsonOutput = JSON.parse(result.stdout.trim());
} catch (parseError) {
// If direct parsing fails, try extracting JSON from mixed output
const lines = result.stdout.split('\n');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a bug in the output. Let's not block on this, something to look into in the future.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make --workspace-folder default to "." (current directory)

2 participants