Skip to content

fix: prevent working directory corruption during goofys install#89

Open
lucabarak wants to merge 1 commit intosentient-agi:mainfrom
lucabarak:fix/setup-profile-discovery-cwd
Open

fix: prevent working directory corruption during goofys install#89
lucabarak wants to merge 1 commit intosentient-agi:mainfrom
lucabarak:fix/setup-profile-discovery-cwd

Conversation

@lucabarak
Copy link

Problem

Running just setup fails with ✗ No profiles found in config/profiles even though profiles exist in that directory (fixes #86).

Root Cause

The install_goofys function in setup.sh uses cd to change into a temporary build directory. When the build fails (which is common — goofys requires Go and specific dependencies), the cleanup path using cd - doesn't properly restore the original working directory:

  1. cd "$temp_dir" — changes to temp dir (OLDPWD = SCRIPT_DIR)
  2. cd goofys — changes again (OLDPWD = temp_dir)
  3. On failure, cd - goes back to temp_dir (not SCRIPT_DIR)
  4. rm -rf "$temp_dir" deletes the current working directory

After this, discover_profiles resolves config/profiles relative to a deleted directory and finds nothing.

Fix

  • Replace cd/cd - with pushd/popd in install_goofys to properly manage the directory stack across all code paths
  • Add cd "$SCRIPT_DIR" safety net at the start of select_profile as defense-in-depth

Testing

Verified that discover_profiles correctly finds all 3 profiles (crypto_agent, general, test) after the fix is applied, even when the goofys build path fails.

…rruption

The goofys build process used cd to change into a temporary directory,
but on failure paths cd - could leave the working directory in a deleted
temp dir instead of returning to SCRIPT_DIR. This caused discover_profiles
to fail with "No profiles found" since config/profiles was resolved
relative to the (now deleted) working directory.

Changes:
- Replace cd/cd - with pushd/popd in install_goofys to properly
  manage directory stack across all success and failure paths
- Add cd $SCRIPT_DIR safety net at the start of select_profile as
  defense-in-depth against any future directory side effects

Fixes sentient-agi#86
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.

just setup output ✗ No profiles found in config/profiles error: Recipe setup failed on line 73 with exit code 1

1 participant