Skip to content

[native_toolchain_c] check null instead of assert #2110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

MichealReed
Copy link
Contributor

@MichealReed MichealReed commented Mar 19, 2025

Given that there are multiple paths to resolve a tool, we should not assert if null, but instead avoid parsing the path if null.

Partially fixes #2109. NDK now resolves, other tools may still have errors.

@MichealReed MichealReed changed the title check null instead of assert [native_toolchain_c] check null instead of assert Mar 19, 2025
Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

@coveralls
Copy link

coveralls commented Mar 20, 2025

Coverage Status

coverage: 85.96% (-0.7%) from 86.693%
when pulling 369e973 on MichealReed:fix-tool-resolver-error
into 543902c on dart-lang:main.

@@ -208,11 +208,12 @@ class InstallLocationResolver implements ToolResolver {
Future<List<Uri>> tryResolvePath(String path) async {
if (path.startsWith(home)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it starts with $HOME, and homeDir_ is null, shouldn't we simply return []; early?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wondering why this could ever be null anyway, it should not be.

#2112

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you still want to null check this? or should we close it? Maybe an env issue could still cause null here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah it wouldn't hurt to check and return [] if there is no home. Then at least the code doesn't crash if the home path environment variable isn't set. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, should be all set now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for your contributions @MichealReed ! 🙏

@dcharkes dcharkes merged commit f1fa5be into dart-lang:main Mar 20, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[native_toolchain_c] Tools do not resolve from build hook on Windows.
3 participants