Skip to content

fix: resolve folder-wide manim.cfg relative to the scene file, not the cwd - #5014

Open
Selahattinozdmr wants to merge 1 commit into
ManimCommunity:mainfrom
Selahattinozdmr:fix/manim-cfg-relative-to-scene-file
Open

Selahattinozdmr wants to merge 1 commit into
ManimCommunity:mainfrom
Selahattinozdmr:fix/manim-cfg-relative-to-scene-file

Conversation

@Selahattinozdmr

Copy link
Copy Markdown

Summary

The folder-wide manim.cfg was being located via a bare relative Path("manim.cfg") in config_file_paths(), which configparser resolves against the current working directory. This lookup happens at import time, before the CLI has parsed args.file, so the documented behavior did not hold:

Manim will look for a manim.cfg config file in the same directory as the file being rendered, and not in the directory of execution.

Running manim src/myanimation/animation1.py from a different directory than the scene file silently ignored src/myanimation/manim.cfg, and instead picked up (or missed) whatever manim.cfg happened to exist in the current working directory.

Fixes #4963

Fix

digest_args now re-digests library-wide + user-wide + the scene file's own directory's manim.cfg as one cascade once args.file is known (skipped when an explicit --config_file was passed, preserving existing precedence rules). This also fixes a secondary correctness issue: options the scene folder's config doesn't set now correctly fall back to the library defaults, instead of keeping whatever value a wrong cwd-based config had already set at import time.

Test plan

  • Added test_folder_wide_config_resolves_relative_to_scene_file, which renders from a scene file in one directory while simulating stray config contamination, and asserts both that the scene folder's manim.cfg value is applied and that untouched options fall back to library defaults rather than leaking the contamination.
  • pytest tests/test_config.py — 44 passed (6 unrelated failures in this sandbox are due to latex/LaTeX not being installed in the minimal test container, not this change)
  • ruff check / ruff format --check clean

🤖 Generated with Claude Code

@Selahattinozdmr
Selahattinozdmr force-pushed the fix/manim-cfg-relative-to-scene-file branch from 4c17082 to 1d97ca6 Compare September 13, 2026 11:31
…e cwd

The folder-wide manim.cfg was being read at import time via a bare
relative Path("manim.cfg"), which configparser resolves against the
current working directory. This happens before the CLI has parsed
args.file, so the documented behavior ("manim will look for a
manim.cfg config file in the same directory as the file being
rendered, and not in the directory of execution") did not hold:
running `manim src/scene.py` from a different directory than the
scene file silently ignored `src/manim.cfg`.

digest_args now re-digests library-wide + user-wide + the scene
file's own directory as one cascade once args.file is known, so the
folder-wide file is resolved relative to the scene, not to cwd. This
also fixes a stray-value leak: options the scene folder's config
doesn't set now correctly fall back to the library defaults instead
of keeping whatever a wrong cwd-based config had set.

Fixes ManimCommunity#4963
@Selahattinozdmr
Selahattinozdmr force-pushed the fix/manim-cfg-relative-to-scene-file branch from 1d97ca6 to bd4ec65 Compare September 13, 2026 11:43
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.

manim.cfg reading not working as expected

1 participant