Repository navigation
fix: Ensure dart sdk path is found correctly from compiled code as well - #4480
Conversation
|
Tests will follow in #4475 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughAdds dynamic Dart SDK discovery and validation to the endpoints analyzer by implementing multiple fallback strategies: resolving from the running dart executable, checking environment variables (DART_SDK, FLUTTER_ROOT), and searching PATH. These utilities enable analysis context initialization with an explicit SDK path to support installations via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tools/serverpod_cli/lib/src/analyzer/dart/endpoints_analyzer.dart(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.dart: Follow Dart formatting conventions with dart format command
Run 'dart format .' to format all code before committing
Run 'melos lint_strict' or 'util/run_tests_analyze' to check code quality before committing, ensuring compliance with CI strict mode
Files:
tools/serverpod_cli/lib/src/analyzer/dart/endpoints_analyzer.dart
🧠 Learnings (2)
📓 Common learnings
Learnt from: tp
Repo: serverpod/serverpod PR: 3721
File: util/pub_get_all:0-0
Timestamp: 2025-06-27T08:39:36.440Z
Learning: In the Serverpod project, `dart pub get` commands work fine on Flutter packages both locally and in CI environments, even when the package has `flutter: sdk: flutter` dependencies in pubspec.yaml. The technical constraint of Flutter SDK dependencies causing `dart pub` failures may not apply in all environments or recent Dart versions.
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Verify example projects still work before submitting PR by running example servers with 'dart bin/main.dart --apply-migrations'
📚 Learning: 2025-06-27T08:39:36.440Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3721
File: util/pub_get_all:0-0
Timestamp: 2025-06-27T08:39:36.440Z
Learning: In the Serverpod project, `dart pub get` commands work fine on Flutter packages both locally and in CI environments, even when the package has `flutter: sdk: flutter` dependencies in pubspec.yaml. The technical constraint of Flutter SDK dependencies causing `dart pub` failures may not apply in all environments or recent Dart versions.
Applied to files:
tools/serverpod_cli/lib/src/analyzer/dart/endpoints_analyzer.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
- GitHub Check: Unit tests IO (3.32.0, windows-latest)
- GitHub Check: Bootstrap tests (3.38.4, windows-latest, tests/bootstrap_project)
- GitHub Check: Bootstrap tests (3.32.0, windows-latest, tests/bootstrap_project)
- GitHub Check: Serverpod E2E web tests (3.32.0)
- GitHub Check: Migration e2e tests (3.38.4)
- GitHub Check: Bootstrap tests (3.38.4, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: Migration e2e tests (3.32.0)
- GitHub Check: Serverpod E2E web tests (3.38.4)
- GitHub Check: CLI e2e tests (3.32.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: Bootstrap tests (3.32.0, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: CLI e2e tests (3.38.4, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: Serverpod integration tests (server) (3.32.0)
- GitHub Check: Serverpod integration tests (server) (3.38.4)
- GitHub Check: dart analyze (3.32.0, windows-latest)
- GitHub Check: dart analyze downgrade (3.38.4, windows-latest)
- GitHub Check: dart analyze downgrade (3.32.0, windows-latest)
🔇 Additional comments (3)
tools/serverpod_cli/lib/src/analyzer/dart/endpoints_analyzer.dart (3)
32-32: LGTM! Clean integration of SDK discovery.The
sdkPathparameter correctly uses the nullable return value from_findDartSdk(), allowing the analyzer to fall back to default SDK discovery when needed.
366-378: LGTM! Correct handling of Flutter and pure Dart SDK layouts.The function properly:
- Uses
basenameWithoutExtensionto handledart.exeon Windows- Checks Flutter layout (
bin/cache/dart-sdk) before pure Dart layout- Returns null when the executable isn't named 'dart' or SDK isn't found
380-380: SDK validation approach is sound and comprehensive.The implementation correctly validates SDK existence by checking for the
versionfile, which is a standard marker in all Dart SDK installations. The broader SDK discovery logic already handles cross-platform scenarios and multiple installation methods: it checksDART_SDKandFLUTTER_ROOTenvironment variables, falls back to PATH using platform-specific commands (whichon Unix,whereon Windows), resolves symlinks properly, and handles both Flutter-bundled and pure Dart installations. No further verification needed.
|
Remember ..
|
Description
Fix Dart SDK discovery for AOT-compiled serverpod CLI.
AnalysisContextCollectioncannot auto-detect SDK when running as compiled executable_findDartSdk()to explicitly locate SDK pathPlatform.resolvedExecutablefirst (works when running viadart run)DART_SDKandFLUTTER_ROOTenv varsdartvia PATH and resolve symlinkssdk/bin/dart) and Flutter (flutter/bin/cache/dart-sdk) layoutsFixes #4481
Pre-launch Checklist
///).Breaking changes
None.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.