[BUG]: os.chdir() Changes the Process-Wide Working Directory During Repository Sync

Aperta Adatta ai principianti
#59 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@aadityachhipa80-oss ci sta già lavorando.

Dal 19/11/2026.

  • #70 di @aadityachhipa80-oss — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
devtools

Direzione di ricerca

Leggi scripts/update_subtrees.py, concentrandoti su sync_all_subtrees() e sulla chiamata os.chdir(bot_root). Segui il modo in cui vengono costruiti i percorsi e verifica se la funzione o i suoi chiamanti dipendono dalla directory di lavoro del processo. Il lavoro è completato quando la sincronizzazione lascia invariata la directory di lavoro e i percorsi relativi, come gap_log.json, continuano a essere risolti in modo coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug enhancement
Bug Description

The sync_all_subtrees() function in scripts/update_subtrees.py uses os.chdir(bot_root) to change the current working directory of the Python process during repository synchronization.

The os.chdir() function changes the working directory globally for the entire process, rather than only for the repository synchronization function.

This can cause unexpected behavior when SkillBot is launched from a directory other than its project root. Relative file paths used by other parts of the application may resolve to different locations after repository synchronization changes the working directory.

For example, a relative path such as gap_log.json may initially resolve relative to the directory from which SkillBot was launched. After os.chdir(bot_root) executes, the same relative path resolves relative to the SkillBot project directory.

As a result, files may be read from or written to unexpected locations, potentially causing missing or misplaced gap-log entries.

Root Cause:

  • sync_all_subtrees() calls os.chdir(bot_root) during repository synchronization.
  • os.chdir() modifies the current working directory for the entire Python process.
  • Other application components that use relative file paths are affected by this global directory change.
  • The working directory may change unexpectedly when SkillBot is launched from outside its project root.
  • Repository synchronization does not need to change the process-wide working directory because the relevant paths are already constructed using bot_root.

Expected Behavior:

Repository synchronization should operate using explicitly resolved paths without changing the process-wide working directory.

The application's current working directory should remain unchanged after repository synchronization, and relative file paths used by other components should continue resolving consistently.

Actual Behavior:

The call to os.chdir(bot_root) changes the working directory globally during repository synchronization. Consequently, relative paths used by other application components may resolve to different locations before and after synchronization.

Impact:

This can cause files to be accessed or created in unexpected directories when SkillBot is launched from a location other than its project root.

It may also result in gap-log entries being written to a different file location, making previously stored entries appear missing or causing the application to use an unintended gap log.

The issue primarily affects non-default launch scenarios where the initial working directory differs from the SkillBot project directory.

Steps to Reproduce
  1. Set up the SkillBot project with its required Python dependencies and environment configuration.
  2. Open a terminal and navigate to a directory outside the SkillBot project root.
  3. Start the SkillBot application using its script or entry point while keeping the terminal's current working directory unchanged.
  4. Before repository synchronization runs, record the application's current working directory using os.getcwd().
  5. Check how a relative file path such as gap_log.json resolves before synchronization.
  6. Allow the repository synchronization process to execute sync_all_subtrees() in scripts/update_subtrees.py.
  7. Observe the execution of os.chdir(bot_root) inside the synchronization workflow.
  8. After synchronization, check the current working directory again using os.getcwd().
  9. Resolve the same relative file path, such as gap_log.json, again and compare its location with the location obtained before synchronization.

Expected Result:

  • Repository synchronization should not modify the process-wide current working directory.
  • The current working directory should remain unchanged before and after synchronization.
  • Relative file paths should continue resolving to the same locations throughout the application's execution.

Actual Result:

The os.chdir(bot_root) call changes the process-wide working directory during repository synchronization. Relative file paths can consequently resolve to different locations after synchronization.

Additional Observation:

The repository synchronization code already constructs its relevant paths using bot_root as an absolute path. Therefore, changing the process-wide working directory is unnecessary for resolving those paths.

Logs and Screenshots

No response

Environment Details

Application: SkillBot (Discord Bot)
Operating System: Windows 11
Programming Language: Python 3.11.3
Affected File: scripts/update_subtrees.py
Affected Function: sync_all_subtrees()
Affected Operation: os.chdir(bot_root)
Related Component: Repository synchronization
Affected Resource: Process-wide current working directory
Related Application Behavior: Relative file path resolution
Example Affected File: gap_log.json

Impact

Medium - Feature works but has issues

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Lingua principale
Python
Stelle
10
Fork
11
Merge medio
6m
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/SkillBot

Tutte le issue di AOSSIE-Org/SkillBot

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.