Skip to content

fix: use basename(workspace) instead of repoName for workspaceFolder#126

Open
sdiazbarraza wants to merge 2 commits into
athal7:mainfrom
sdiazbarraza:fix/workspace-folder-basename-v2
Open

fix: use basename(workspace) instead of repoName for workspaceFolder#126
sdiazbarraza wants to merge 2 commits into
athal7:mainfrom
sdiazbarraza:fix/workspace-folder-basename-v2

Conversation

@sdiazbarraza

Copy link
Copy Markdown

Summary

  • Fix: Use basename(workspace) instead of repoName for workspaceFolder and container name in generateOverrideConfig
  • Test: Add test case to verify basename(workspace) takes precedence over repoName when both are provided

Changes

Fix (config.js)

// Before
const workspaceName = repoName || basename(workspace)

// After
const workspaceName = basename(workspace) || repoName

Test (config.test.js)

  • Updated existing test to expect basename(workspace) for workspaceFolder
  • Added new test prefers basename(workspace) over repoName when both provided

Testing

  • All 21 config tests pass

Checklist

  • Tests added/updated
  • Tests pass (npm test)
  • Commit messages follow conventional commit format

The override config was setting workspaceFolder to /workspaces/{repoName} instead of /workspaces/{basename(workspace)}, causing container exec to fail when branch folder name differs from repo name (e.g. feature/login vs carro-smart)
Adds a test case that verifies basename(workspace) is used for workspaceFolder
and container name, taking precedence over the repoName parameter when both
are provided.
@DarkMatterV

Copy link
Copy Markdown

I encountered the same issue. repoName is devcontainer_demo, "/devcontainer new_a" clone to ~/.local/share/opencode/clone/devcontainer_demo/new_d.

--workspace-folder is used as ~/.local/share/opencode/clone/devcontainer_demo/new_d, and the path in the created Docker container is /workspaces/new_d.

In override-config, workspaceFolder is the repo name, that is, devcontainer_demo.

The error log in jobs.json is as follows:
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "chdir to cwd (\"/workspaces/devcontainer_demo\") set in config.json failed: no such file or directory

I am not very familiar with devcontainer. I asked opencode to help me locate the fault. The explanation is as follows:

The devcontainer CLI reads the workspaceFolder field in override.json.
The CLI translates the value into docker exec -w /workspaces/devcontainer_demo...
The dockerd generates an OCI runtime spec for this exec and writes it to config.json.
(The cwd field is "/workspaces/devcontainer_demo".)

I am not sure whether this is correct or whether it is related to the DinD deployment. (I started the docker daemon in the Kubernetes pod and executed opencode /devcontainer.)

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.

2 participants