-
Notifications
You must be signed in to change notification settings - Fork 136
When installed from local project clone, install.sh deletes project directory #121
Description
When running ./install.sh from a clone of the repo (rather than via curl | bash), the installer identifies the current working directory as an "old installation" and rm -rfs it after completing the install to ~/.claude-code-docs.
I discovered this while working on some contributions for a PR. There is a check for any uncommitted changes, but if everything has been committed but not yet pushed it still gets nuked.
Fix is probably, when checking if pwd == $INSTALL_DIR, also check against script's location.
Another possibility might be to evaluate if the migration logic has outlived its usefulness. At some point, any installations of the tool will be to the proper location and not need to be migrated. In theory, it should be okay to remove this logic completely at some point. It's quite complicated and could be the source of more issues.
Detailed analysis follows:
Root Cause
Three pieces of code combine to cause this:
-
find_existing_installations()(line 107-109) adds$(pwd)to the old installations list if./docs/docs_manifest.jsonexists and the CWD isn't~/.claude-code-docs:if [[ -f "./docs/docs_manifest.json" && "$(pwd)" != "$INSTALL_DIR" ]]; then paths+=("$(pwd)") fi
-
That path gets saved into the
OLD_INSTALLATIONSarray (line 345). -
After installing/updating to
~/.claude-code-docs,cleanup_old_installations()(line 498) iteratesOLD_INSTALLATIONSand deletes any that are clean git repos:if [[ -z "$(git status --porcelain 2>/dev/null)" ]]; then cd - >/dev/null rm -rf "$old_dir"
Steps to Reproduce
- Clone the repo to any location other than
~/.claude-code-docs(e.g.,~/work/claude-code-docs) - Ensure the working tree is clean (
git statusshows nothing) - Run
./install.shfrom that directory - The directory you ran the script from is deleted
Suggested Fix
Exclude the script's own directory from the old installations list, or skip it during cleanup. For example:
SCRIPT_DIR="$(cd "$(dirname "0ドル")" && pwd)" # In find_existing_installations(), change the CWD check: if [[ -f "./docs/docs_manifest.json" && "$(pwd)" != "$INSTALL_DIR" && "$(pwd)" != "$SCRIPT_DIR" ]]; then paths+=("$(pwd)") fi