Skip to content

feat(apple): Fix doctor issue with asdf - #6062

Merged
NathanWalker merged 5 commits into
NativeScript:mainfrom
apburgess:fix-doctor-issue-with-asdf
Jul 28, 2026
Merged

feat(apple): Fix doctor issue with asdf#6062
NathanWalker merged 5 commits into
NativeScript:mainfrom
apburgess:fix-doctor-issue-with-asdf

Conversation

@apburgess

@apburgess apburgess commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Currently iOS builds can fail in the ns doctor stage when using asdf to specify the Ruby version; this happens because the CocoaPods checks performed by ns doctor are done in a new directory in /tmp which is missing the asdf configuration.

What is the new behavior?

If asdf is installed, the Ruby version specified for the project is added to a .tool-versions file in the CocoaPods test project folder; this stops the ns doctor command from failing and lets the build continue.

Implements #6061.

Note: I have run the existing tests; the only test that fails is 'skip when missing hook args' - but this also fails on a clean clone from the repo.

Summary by CodeRabbit

  • New Features
    • CocoaPods verification now detects ASDF-managed Ruby setups and records the active Ruby version in the Ruby version configuration when found.
  • Bug Fixes
    • Improved diagnostic logging when CocoaPods commands fail for clearer troubleshooting.
    • Enhanced file append behavior used during ASDF detection: returns reliable success/failure and reports append errors.
  • Tests
    • Added coverage for ASDF-based CocoaPods health checks, including verification of command options and .tool-versions updates.

apburgess added 3 commits June 4, 2026 19:22
If the user is using ASDF the 'doctor' command may fail at the Cocoapods stage as it will be using the global tool definitions instead of those specified by the project (if any).  This fixes the problem by generating a .tool-versions file with the correct settings in the temp directory used for the Cocoapods test.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 88269714-99e6-4fe2-8554-90c3845c9a56

📥 Commits

Reviewing files that changed from the base of the PR and between b0f2371 and 6a10370.

📒 Files selected for processing (2)
  • packages/doctor/src/sys-info.ts
  • packages/doctor/test/sys-info.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/doctor/src/sys-info.ts

📝 Walkthrough

Walkthrough

FileSystem gains synchronous file appending. SysInfo.isCocoaPodsWorkingCorrectly detects an ASDF-managed Ruby version and writes it to the temporary CocoaPods project’s .tool-versions file, with tests covering detected and unavailable ASDF cases.

Changes

ASDF Ruby Support in CocoaPods Verification

Layer / File(s) Summary
FileSystem.appendFile method
packages/doctor/src/wrappers/file-system.ts
Adds synchronous file appending with boolean success reporting and error logging; adjacent punctuation-only changes are included.
ASDF detection, injection, and validation
packages/doctor/src/sys-info.ts, packages/doctor/test/sys-info.ts
Probes asdf current ruby, appends ruby <version> to .tool-versions, logs pod install failures, and tests ASDF-present and ASDF-unavailable cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐇 I sniffed out Ruby, quick and bright,
ASDF tucked the version right.
Into tool-versions, neat and true,
CocoaPods knew just what to do.
Hop, hop—no mystery in the brew!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing ns doctor behavior when asdf manages Ruby.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/doctor/src/sys-info.ts`:
- Around line 429-444: The asdf probe in the spawnFromEvent call at line 429
unconditionally fails if asdf is missing or misconfigured, causing healthy
setups to incorrectly report as broken. Additionally, using asdf list ruby may
match a non-active version instead of the currently active one. Add ignoreError:
true option to the spawnFromEvent call to prevent throwing, change the asdf
command from "list ruby" to "current ruby" to explicitly resolve the active
project Ruby version (which outputs the specific active version and
configuration source), and update the version matching logic if needed to work
with the output format of asdf current ruby.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4a87b1a9-ab68-4240-9fb0-55de6c4fd509

📥 Commits

Reviewing files that changed from the base of the PR and between 86cb6a5 and 71e4e71.

📒 Files selected for processing (2)
  • packages/doctor/src/sys-info.ts
  • packages/doctor/src/wrappers/file-system.ts

Comment thread packages/doctor/src/sys-info.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
packages/doctor/src/sys-info.ts (1)

447-450: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Terminate the appended .tool-versions entry with a newline.

At Line 449, appending ruby ${asdfVersion} without EOL can merge with existing content in .tool-versions and produce an invalid line when the file is pre-populated.

Suggested patch
 							const wroteASDFConfig = this.fileSystem.appendFile(
 								asdfConfigPath,
-								`ruby ${asdfVersion}`,
+								`ruby ${asdfVersion}${EOL}`,
 							);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/doctor/src/sys-info.ts` around lines 447 - 450, The appendFile call
in the asdfConfigPath section is appending `ruby ${asdfVersion}` without a
trailing newline character, which will cause the content to merge with existing
entries in the pre-populated `.tool-versions` file and create invalid lines. Add
a newline character (EOL or \n) at the end of the template string being appended
in the appendFile call for asdfConfigPath to ensure each entry is properly
terminated and on its own line.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@packages/doctor/src/sys-info.ts`:
- Around line 447-450: The appendFile call in the asdfConfigPath section is
appending `ruby ${asdfVersion}` without a trailing newline character, which will
cause the content to merge with existing entries in the pre-populated
`.tool-versions` file and create invalid lines. Add a newline character (EOL or
\n) at the end of the template string being appended in the appendFile call for
asdfConfigPath to ensure each entry is properly terminated and on its own line.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 39b2db4a-fa53-4b30-b4f8-87d7f248a641

📥 Commits

Reviewing files that changed from the base of the PR and between 71e4e71 and b0f2371.

📒 Files selected for processing (1)
  • packages/doctor/src/sys-info.ts

["current", "ruby"],
"exit",
{ ignoreError: true },
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should set cwd since ns doctor can be run outside of project directories.

Comment thread packages/doctor/src/sys-info.ts Outdated
);
const wroteASDFConfig = this.fileSystem.appendFile(
asdfConfigPath,
`ruby ${asdfVersion}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
`ruby ${asdfVersion}`,
`ruby ${asdfVersion}\n`

@NathanWalker NathanWalker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just two nit's on version resolution being cwd explicit, a trailing newline for the tools etiquette (ensuring other appends don't mash together), and if possible to add a small unit test around asdf-present/asdf-absent behavior would be 💯 thank you!

@NathanWalker

Copy link
Copy Markdown
Contributor

@apburgess possible to enable 'Allow edit from maintainers' on your fork? I could push small adjustment to get this merged 👍

@NathanWalker

Copy link
Copy Markdown
Contributor

See this as reference to adjustment: https://github.com/NativeScript/nativescript-cli/pull/6086/changes - you can make here if you'd like and happy to merge yours instead.

@apburgess

Copy link
Copy Markdown
Contributor Author

@NathanWalker Apologies, I was off on another project and kept meaning to get back to this; I've added 'Allow edits from maintainers' but #6086 seems to cover the outstanding bits, thanks!

Resolve the asdf Ruby version with an explicit cwd so it reflects the
project even when `ns doctor` is invoked outside the project directory,
and newline-terminate the `.tool-versions` entry so it cannot merge with
existing content. Adds unit tests for the asdf-present and asdf-absent
paths.
@NathanWalker

Copy link
Copy Markdown
Contributor

Excellent thank you @apburgess, pushed up small nit's and this can proceed now 💯

@NathanWalker
NathanWalker merged commit a273145 into NativeScript:main Jul 28, 2026
6 of 7 checks passed
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