dagger/dagger · error

--global writes to user-level config; pass KEY VALUE to set

Error message

--global writes to user-level config; pass KEY VALUE to set or --unset KEY (reads always show the effective merged config)

What it means

Argument validation error from `dagger workspace config --global`: --global writes to user-level config, which supports only KEY VALUE writes (2 args) or --unset KEY (1 arg). Reads of the effective merged config are done without --global, so --global with fewer than 2 arguments (and no --unset) is rejected with this explanatory message.

Source

Thrown at internal/cmd/dagger/workspace.go:263

	addWorkspaceHereFlag(workspaceConfigCmd)
	activityCmd.Flags().BoolVarP(&workspaceActivityAll, "all", "a", false, "Show activity from all remotes in the current workspace")
}

func addWorkspaceHereFlag(cmd *cobra.Command) {
	cmd.Flags().BoolVar(&workspaceHere, "here", false, "Write workspace config at the selected workspace cwd")
}

func runWorkspaceConfig(cmd *cobra.Command, args []string) error {
	if workspaceConfigUnset && len(args) != 1 {
		return fmt.Errorf("--unset requires a KEY argument")
	}
	if workspaceConfigGlobal {
		ctx := cmd.Context()
		if workspaceConfigUnset {
			return unsetUserConfigValue(ctx, userScopedConfigKey(args[0]))
		}
		if len(args) != 2 {
			return fmt.Errorf("--global writes to user-level config; pass KEY VALUE to set or --unset KEY (reads always show the effective merged config)")
		}
		return writeUserConfigValue(ctx, userScopedConfigKey(args[0]), args[1], nil)
	}
	return withEngine(cmd.Context(), client.Params{
		SkipWorkspaceModules:           true,
		SuppressCompatWorkspaceWarning: true,
	}, func(ctx context.Context, engineClient *client.Client) error {
		ws := engineClient.Dagger().CurrentWorkspace()

		if workspaceConfigUnset {
			return ws.WithoutConfigValue(args[0], dagger.WorkspaceWithoutConfigValueOpts{Here: workspaceHere}).Export(ctx)
		}

		switch len(args) {
		case 0:
			return printWorkspaceConfig(ctx, cmd.OutOrStdout(), ws, "")
		case 1:
			return printWorkspaceConfig(ctx, cmd.OutOrStdout(), ws, args[0])

View on GitHub (pinned to 82ba2681db)

Solutions

  1. For writes, pass exactly two arguments: `dagger workspace config --global KEY VALUE`.
  2. For reads, drop --global: `dagger workspace config` or `dagger workspace config KEY` shows the effective merged config.
  3. For removal, use `dagger workspace config --global --unset KEY`.
  4. Note the write is keyed by the workspace's git remote; ensure the workspace has a git origin.

Example fix

// before
dagger workspace config --global autocheck
// error: --global writes to user-level config; pass KEY VALUE ...
// after
dagger workspace config autocheck              # read (merged)
dagger workspace config --global autocheck on  # write
Defensive patterns

Strategy: validation

Validate before calling

if global && !unset && len(args) != 2 {
    return fmt.Errorf("--global requires KEY VALUE")
}
// reads:
// dagger workspace config KEY      (no --global)
// writes:
// dagger workspace config --global KEY VALUE

Prevention

When it happens

Trigger: Running `dagger workspace config --global` with 0 arguments (intending a read), or `dagger workspace config --global KEY` with only one argument (intending a read of one key, or omitting the VALUE).

Common situations: Assuming --global also applies to reads; omitting the value in a scripted set; migrating from a plain `dagger workspace config KEY` read and adding --global by habit.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/229c0ff30f5ef8ca. Report an issue: GitHub.