Skip to content

Workspace.path does not always return the workspace path #13051

Closed

Description

@shykes

Problem

Workspace.path should return the path of the detected workspace. Today, in some cases, it returns the path where workspace detection started.

Repro:

cd PATH/TO/WORKSPACE/subdir
dagger core current-workspace path
# actual: subdir
# expected: . or the detected workspace path

This is inconsistent with:

dagger core current-workspace directory --path=.

which loads the detected workspace, not subdir.

Likely cause: core/workspace/detect.go sets Path from the detection start:

Root: gitDir,
Path: relPath(gitDir, cwd),

Solution

Separate workspace identity from detection start:

extend type Workspace {
  """The current working directory within the workspace."""
  cwd: WorkspaceCwd!
}

"""The current working directory within the workspace. This is set to the directory where workspace detection started, and cannot be changed."""
type WorkspaceCwd {
  """Location of the current working directory within the workspace, relative to the workspace root. Empty string means the workspace root."""
  path: String!

  """Returns a Directory from the current working directory. Relative paths resolve from this cwd."""
  directory(path: String!, exclude: [String!], include: [String!], gitignore: Boolean = false): Directory!

  """Returns a File from the current working directory. Relative paths resolve from this cwd."""
  file(path: String!): File!
}

Semantics:

  • Workspace.path always reports the detected workspace path.
  • Workspace.directory(".") keeps loading the detected workspace.
  • Workspace.cwd.path reports the cwd offset.
  • Workspace.cwd.directory(".") loads the cwd.
  • Explicit local and remote workspace refs follow the same model.

Activity

  1. added a commit that references this issue on Apr 29, 2026
    b4f2f8b
  2. added a commit that references this issue on May 5, 2026
    77611b0
  3. added a commit that references this issue on May 5, 2026
    a2e3508
  4. added 12 commits that reference this issue on May 6, 2026
    fb03452
    63b8a43
    ad5b8f6
    6c9eb20
    4411b91
    81bd198
    3b49ca5
    1554137
    7dd7da2
    851e66e
    6c04ea5
    32b9fe9
  5. 5 remaining items

  6. added 4 commits that reference this issue on May 20, 2026
    49aad75
    028f25b
    817bed3
    46f8bb3
  7. added 3 commits that reference this issue on May 27, 2026
    990050e
    487e37d
    0839796
  8. added 2 commits that reference this issue on May 29, 2026
    b59e76b
    5bd5702
  9. added 2 commits that reference this issue on May 30, 2026
    835b4c1
    f789778
  10. added a commit that references this issue on Jun 1, 2026
    9c0e0dd
  11. added a commit that references this issue on Jun 1, 2026
    761dc25
  12. added a commit that references this issue on Jun 1, 2026
    e81b4a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions