Skip to content

Expand tilde (~) in config paths like derivedDataPath#301

Closed
trmquang93 wants to merge 4 commits intogetsentry:mainfrom
trmquang93:fix/283-expand-tilde-in-config-paths
Closed

Expand tilde (~) in config paths like derivedDataPath#301
trmquang93 wants to merge 4 commits intogetsentry:mainfrom
trmquang93:fix/283-expand-tilde-in-config-paths

Conversation

@trmquang93
Copy link
Copy Markdown
Contributor

Summary

Fixes #283

Paths containing ~ (e.g. ~/.derivedData) in config were not expanded, causing a literal ~ directory to be created in the project root instead of resolving to the user's home directory.

Changes

Added tilde expansion in two path resolution functions:

  • resolvePathFromCwd in build-utils.ts -- handles runtime path resolution when building
  • normalizePathValue in project-config.ts -- handles path resolution when loading config.yaml

Both functions now expand ~ and ~/... to the user's home directory before checking if the path is absolute or resolving relative to cwd.

This enables shared config files (committed to the repo) to use ~/... paths that resolve correctly across team members with different home directories, as described in the issue.

Test plan

  • Added test in build-utils.test.ts: verifies ~/.derivedData/test expands to $HOME/.derivedData/test in xcodebuild command
  • Added test in project-config.test.ts: verifies ~/.derivedData/myproject expands correctly when loaded from YAML config
  • All existing tests pass (35 tests across both files)
  • Pre-commit hooks (format, lint, build, tests) pass

…etsentry#287)

The list_devices tool included deviceId in nextStepParams for
build_device, but build_device does not accept a deviceId parameter
(it builds generically for the iOS device platform). This caused the
CLI to render an invalid suggestion like:
  xcodebuildmcp device build --device-id "DEVICE_UDID"

Remove deviceId from build_device's nextStepParams. The build_run_device
and test_device entries correctly retain deviceId since those tools
require it.
Paths containing ~ (e.g. ~/.derivedData) were not expanded, causing a
literal ~ directory to be created in the project root. Add tilde
expansion in both path resolution functions:

- resolvePathFromCwd in build-utils.ts (runtime path resolution)
- normalizePathValue in project-config.ts (config YAML loading)

This allows shared config files to use ~/... paths that work across
team members with different home directories.
Comment thread src/utils/build-utils.ts Outdated
The duplicate resolvePathFromCwd in build-settings.ts was missing
tilde expansion. This caused derivedDataPath with ~ to work during
builds but fail when resolving app paths from build settings (used
by build_run_device and get_device_app_path).
Copy link
Copy Markdown
Contributor

@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.

Comment thread src/utils/build-utils.ts Outdated
Move the tilde expansion logic into a shared utils/expand-home.ts
module and use it from all four call sites: build-utils.ts,
project-config.ts, build-settings.ts, and cli/commands/init.ts.

The shared version handles both ~/ and ~\ (Windows) consistently,
matching the behavior that was previously only in init.ts.
@cameroncooke
Copy link
Copy Markdown
Collaborator

Hi @trmquang93 — first, thank you for filing this fix and for the original implementation work. The reproduction in #283 and the approach you took (a single shared expandHomePrefix utility applied at each path entry point) were both spot-on, and the new PR follows that same shape.

Unfortunately this PR can't be merged as-is. Two issues, both purely mechanical and not a reflection on the change itself:

  1. The targeted code has moved on main since you opened this. Derived-data resolution now flows through resolveEffectiveDerivedDataPath() in src/utils/derived-data-path.ts, and the resolvePathFromCwd helper you modified in src/mcp/tools/device/build-settings.ts no longer exists there (that file has been reduced to platform mapping). A clean rebase is no longer possible — the conflicts can't be resolved without effectively rewriting the patch.
  2. The branch also includes an unrelated commit for [Bug]: Docs/code mismatch: device list recommends --device-id, but device build rejects it #287/Fix build_device next step suggesting unsupported --device-id flag #300, which scopes the PR beyond [Feature]: Expand ~ (tilde) in derived data path passed via config #283.

I've reimplemented the fix from scratch against current main, keeping your design (shared utility, applied at every relevant entry point — init.ts, build-utils.ts, derived-data-path.ts, project-config.ts) and added unit tests at each layer. The new PR is #370 and credits you in the changelog as the originator.

Going to close this in favor of #370. Thanks again for the contribution — the fix is shipping, just under a different commit hash.

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.

[Feature]: Expand ~ (tilde) in derived data path passed via config

2 participants