Skip to content

feat(cli): add --config option for custom config file path#307

Merged
hubertdeng123 merged 1 commit intomainfrom
feat/custom-config-file
Mar 27, 2026
Merged

feat(cli): add --config option for custom config file path#307
hubertdeng123 merged 1 commit intomainfrom
feat/custom-config-file

Conversation

@hubertdeng123
Copy link
Copy Markdown
Member

Add a global -c/--config CLI option to specify a custom devservices
config file path, bypassing the default config discovery logic (cwd-based
or coderoot service name lookup).

This is useful for testing config changes without modifying the repo's
actual config file, or for pointing at configs in non-standard locations.

When --config is provided:

  • The config is loaded directly from the specified path
  • repo_path is derived from the config file's location (grandparent
    if inside a devservices/ directory, otherwise parent directory)
  • The option is available to all subcommands via the main parser

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (cli) Add --config option for custom config file path by hubertdeng123 in #307
  • Uv by joshuarli in #305

Bug Fixes 🐛

  • (state) Gracefully handle stale service entries in state database by vaind in #302

Internal Changes 🔧

Release

  • Fix changelog-preview permissions by BYK in #300
  • Switch from action-prepare-release to Craft by BYK in #299

Other

  • (deps-dev) Bump setuptools from 70.0.0 to 78.1.1 by dependabot in #294
  • Pin GitHub Actions to full-length commit SHAs by joshuarli in #306

🤖 This preview updates automatically when you update the PR.

@hubertdeng123 hubertdeng123 force-pushed the feat/custom-config-file branch from dad1de8 to 35acf14 Compare March 27, 2026 18:53
Allow users to specify a custom devservices config file via
`devservices --config /path/to/config.yml <command>`, bypassing
the default config discovery logic.
@hubertdeng123 hubertdeng123 force-pushed the feat/custom-config-file branch from 35acf14 to 8f89003 Compare March 27, 2026 18:59
@hubertdeng123 hubertdeng123 requested a review from a team March 27, 2026 19:01
raise ServiceNotFoundError(error_message)
if config_path is not None:
config_path = os.path.abspath(config_path)
repo_path = os.getcwd()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: When using the --config flag, repo_path is incorrectly set to the current working directory instead of being derived from the provided config_path, causing subsequent commands to fail.
Severity: CRITICAL

Suggested Fix

Modify the logic to derive repo_path from the absolute path of the config_path provided. The path should be the grandparent directory if the config is inside a devservices/ directory, or the parent directory otherwise, as stated in the pull request's description.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: devservices/utils/services.py#L63

Potential issue: When a user specifies a custom configuration file using the `--config`
flag, the `repo_path` variable is incorrectly set to the current working directory
(`os.getcwd()`) instead of being derived from the provided `config_path`. Downstream
commands such as `up`, `down`, and `status` rely on `repo_path` to reconstruct the path
to the configuration file. If the command is run from a directory different from the one
containing the config file, this leads to an incorrect path, causing the command to fail
with an error like `ConfigNotFoundError`. This breaks the feature's primary use case of
pointing to configurations in non-standard locations.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

raise ServiceNotFoundError(error_message)
if config_path is not None:
config_path = os.path.abspath(config_path)
repo_path = os.getcwd()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repo_path uses cwd instead of config file location

High Severity

When config_path is provided, repo_path is set to os.getcwd() instead of being derived from the config file's location. The PR description explicitly states repo_path should be the grandparent directory if the config is inside a devservices/ directory, or the parent directory otherwise. All downstream commands reconstruct the config file path as os.path.join(service.repo_path, DEVSERVICES_DIR_NAME, CONFIG_FILE_NAME), so docker-compose, supervisor, and log operations will reference the wrong config file — not the one specified by --config.

Additional Locations (2)
Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member

@joshuarli joshuarli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep looks like python

@hubertdeng123 hubertdeng123 merged commit 6c5fb43 into main Mar 27, 2026
17 checks passed
@hubertdeng123 hubertdeng123 deleted the feat/custom-config-file branch March 27, 2026 22:31
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.

2 participants