Skip to content

fix(plugins): correct sys.path depth in discord/raft platform adapters - #49604

Closed
mojotiger608 wants to merge 1 commit into
NousResearch:mainfrom
mojotiger608:fix/discord-raft-syspath-depth
Closed

fix(plugins): correct sys.path depth in discord/raft platform adapters#49604
mojotiger608 wants to merge 1 commit into
NousResearch:mainfrom
mojotiger608:fix/discord-raft-syspath-depth

Conversation

@mojotiger608

Copy link
Copy Markdown

Problem

plugins/platforms/discord/adapter.py and plugins/platforms/raft/adapter.py
both insert the repo root onto sys.path via:

sys.path.insert(0, str(_Path(__file__).resolve().parents[2]))

This is correct for adapters at gateway/platforms/<name>.py (3 levels
deep, where parents[2] is the repo root), but discord/raft live one
level deeper at plugins/platforms/<name>/adapter.py, so parents[2]
resolves to the plugins/ directory instead of the repo root.

Since discord-platform and raft-platform are kind: platform and
auto-load unconditionally on every PluginManager.discover_and_load()
call (no opt-in required), this silently inserts plugins/ at
sys.path[0] on every process that runs plugin discovery — which is
effectively every hermes-agent / hermes-webui startup.

From that point on, any import cron in the same process resolves to
plugins/cron/__init__.py (the bundled cron-provider discovery shim,
which has no jobs.py/scheduler.py) instead of the real top-level
cron/ scheduler package — causing
ModuleNotFoundError: No module named 'cron.jobs' anywhere downstream
that does from cron.jobs import ... afterward (e.g.
tools/cronjob_tools.py, hermes-webui's /api/crons endpoint).

Fix

Change parents[2] to parents[3] in both files, matching the actual
nesting depth (plugins/platforms/<name>/adapter.py is 4 levels below
the repo root). Verified both files immediately follow with
from gateway.config import ... / from gateway.platforms.base import ...,
confirming the intent was always the repo root.

Verification

Reproduced and fixed in isolation:

# before fix
>>> sys.path[0]
''
>>> PluginManager().discover_and_load()
>>> sys.path[0]
'/repo/plugins'        # wrong
>>> import cron.jobs
ModuleNotFoundError: No module named 'cron.jobs'

# after fix
>>> PluginManager().discover_and_load()
>>> sys.path[0]
'/repo'                # correct
>>> import cron.jobs   # succeeds

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins platform/discord Discord bot adapter P1 High — major feature broken, no workaround duplicate This issue or pull request already exists labels Jun 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #49431 — identical fix (parents[2] -> parents[3] in plugins/platforms/discord/adapter.py and plugins/platforms/raft/adapter.py) for the same root cause: discord/raft platform adapters inserting plugins/ instead of the repo root onto sys.path, shadowing the real cron/ package and causing ModuleNotFoundError downstream. #49431 (by @kyssta-exe) is the earlier open PR with the same two-file, one-line mechanism. See also the cluster: source issue #49410 and the different-mechanism module-level-preimport alternative #49414.

@mojotiger608
mojotiger608 deleted the fix/discord-raft-syspath-depth branch June 20, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P1 High — major feature broken, no workaround platform/discord Discord bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants