You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] install.sh is not idempotent and creates nested src/tmp/template_project on second run #197
Running install.sh a second time in the same target directory creates an unexpected nested folder (src/tmp/template_project/) instead of keeping the workspace clean/idempotent.
Steps to Reproduce
Run: ~/Documents/vigOS/devcontainer/install.sh ./ --version dev --skip-pull --force --org vigOS
Confirm working tree is clean: git status -> nothing to commit, working tree clean
Run the same install command again in the same directory.
Check status: git status -> shows untracked files under src/tmp/template_project/
Expected Behavior
Re-running install.sh on the same directory should be idempotent and should not create additional nested template folders or untracked artifacts.
Actual Behavior
Second execution creates src/tmp/template_project/ as untracked content.
Environment
OS: Linux 6.17.0-14-generic
Container Runtime: N/A (not involved in reproduction)
Image Version/Tag: dev (--version dev)
Architecture: x86_64
Additional Context
Reproduction commands/output provided by reporter:
~/Documents/vigOS/devcontainer/install.sh ./ --version dev --skip-pull --force --org vigOS
git status # clean~/Documents/vigOS/devcontainer/install.sh ./ --version dev --skip-pull --force --org vigOS
git status # shows src/tmp/template_project/
In `assets/init-workspace.sh`, the rename logic at lines 256-259:
```bash
if [[ -d "$WORKSPACE_DIR/src/template_project" ]]; then
mv "$WORKSPACE_DIR/src/template_project" "$WORKSPACE_DIR/src/${SHORT_NAME}"
fi
```
On first run: rsync copies `src/template_project/` from the template, then `mv` renames it to `src/${SHORT_NAME}/`. Correct.
On second run (with `--force`): rsync re-copies `src/template_project/` because it no longer exists in the workspace (it was renamed). Then `mv` attempts to rename it to `src/${SHORT_NAME}`, but that directory already exists. The `mv` command moves `template_project` inside the existing directory, creating `src/${SHORT_NAME}/template_project/`.
Fix
In the rename block, check whether `src/${SHORT_NAME}` already exists. If so, remove the redundant `src/template_project` instead of renaming it. This handles the idempotency case cleanly:
```bash
if [[ -d "$WORKSPACE_DIR/src/template_project" ]]; then
if [[ -d "$WORKSPACE_DIR/src/${SHORT_NAME}" ]] && [[ "$SHORT_NAME" != "template_project" ]]; then
echo "Removing duplicate src/template_project (src/${SHORT_NAME} already exists)..."
rm -rf "$WORKSPACE_DIR/src/template_project"
else
echo "Renaming src/template_project to src/${SHORT_NAME}..."
mv "$WORKSPACE_DIR/src/template_project" "$WORKSPACE_DIR/src/${SHORT_NAME}"
fi
fi
```
Testing Strategy
Add a BATS test to `tests/bats/init-workspace.bats` that verifies the guard clause exists in the script. This matches the existing test pattern (structure/grep tests) since functional testing of init-workspace.sh requires a container environment.
Activity
c-vigo commentedon Feb 25, 2026
Design
Root Cause
In `assets/init-workspace.sh`, the rename logic at lines 256-259:
```bash
if [[ -d "$WORKSPACE_DIR/src/template_project" ]]; then
mv "$WORKSPACE_DIR/src/template_project" "$WORKSPACE_DIR/src/${SHORT_NAME}"
fi
```
On first run: rsync copies `src/template_project/` from the template, then `mv` renames it to `src/${SHORT_NAME}/`. Correct.
On second run (with `--force`): rsync re-copies `src/template_project/` because it no longer exists in the workspace (it was renamed). Then `mv` attempts to rename it to `src/${SHORT_NAME}`, but that directory already exists. The `mv` command moves `template_project` inside the existing directory, creating `src/${SHORT_NAME}/template_project/`.
Fix
In the rename block, check whether `src/${SHORT_NAME}` already exists. If so, remove the redundant `src/template_project` instead of renaming it. This handles the idempotency case cleanly:
```bash
if [[ -d "$WORKSPACE_DIR/src/template_project" ]]; then
if [[ -d "$WORKSPACE_DIR/src/${SHORT_NAME}" ]] && [[ "$SHORT_NAME" != "template_project" ]]; then
echo "Removing duplicate src/template_project (src/${SHORT_NAME} already exists)..."
rm -rf "$WORKSPACE_DIR/src/template_project"
else
echo "Renaming src/template_project to src/${SHORT_NAME}..."
mv "$WORKSPACE_DIR/src/template_project" "$WORKSPACE_DIR/src/${SHORT_NAME}"
fi
fi
```
Testing Strategy
Add a BATS test to `tests/bats/init-workspace.bats` that verifies the guard clause exists in the script. This matches the existing test pattern (structure/grep tests) since functional testing of init-workspace.sh requires a container environment.
Scope
c-vigo commentedon Feb 25, 2026
Implementation Plan
Issue: #197
Branch: bugfix/197-install-sh-idempotent
Tasks
tests/bats/init-workspace.bats— verify:just test-batsassets/init-workspace.sh— verify:just test-batsCHANGELOG.md— verify:grep 'idempotent' CHANGELOG.mdtest: add BATS test for idempotent rename guard in init-workspace.sh
fix(workspace): make init-workspace.sh idempotent for template_projec…
docs(changelog): add entry for install.sh idempotency fix
fix(test): suppress SC2016 in init-workspace BATS test
c-vigo commentedon Feb 25, 2026
Autonomous Run Complete
fix(workspace): make install.sh idempotent for template_project rename (