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

オープン 初心者向け
#59 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@aadityachhipa80-oss がすでに取り組んでいます。

2026年11月19日 から。

  • #70 @aadityachhipa80-oss による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
devtools

調査の方向性

scripts/update_subtrees.pyを読み、sync_all_subtrees()とos.chdir(bot_root)の呼び出しに注目してください。パスがどのように構築されるかを追い、関数またはその呼び出し元がプロセスの作業ディレクトリに依存しているか確認してください。同期後も作業ディレクトリが変わらず、gap_log.jsonのような相対パスが一貫して解決される状態を完了とします。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
10
フォーク
11
平均マージ
6分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/SkillBot のほかの issue

AOSSIE-Org/SkillBot の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。