fix: prevent working directory corruption during goofys install#89
Open
lucabarak wants to merge 1 commit intosentient-agi:mainfrom
Open
fix: prevent working directory corruption during goofys install#89lucabarak wants to merge 1 commit intosentient-agi:mainfrom
lucabarak wants to merge 1 commit intosentient-agi:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running
just setupfails with✗ No profiles found in config/profileseven though profiles exist in that directory (fixes #86).Root Cause
The
install_goofysfunction insetup.shusescdto change into a temporary build directory. When the build fails (which is common — goofys requires Go and specific dependencies), the cleanup path usingcd -doesn't properly restore the original working directory:cd "$temp_dir"— changes to temp dir (OLDPWD = SCRIPT_DIR)cd goofys— changes again (OLDPWD = temp_dir)cd -goes back to temp_dir (not SCRIPT_DIR)rm -rf "$temp_dir"deletes the current working directoryAfter this,
discover_profilesresolvesconfig/profilesrelative to a deleted directory and finds nothing.Fix
cd/cd -withpushd/popdininstall_goofysto properly manage the directory stack across all code pathscd "$SCRIPT_DIR"safety net at the start ofselect_profileas defense-in-depthTesting
Verified that
discover_profilescorrectly finds all 3 profiles (crypto_agent, general, test) after the fix is applied, even when the goofys build path fails.