Skip to content

[dartdev] Could not find dart. Have you built the full Dart SDK? on dart build #56080

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

Closed
dcharkes opened this issue Jun 26, 2024 · 10 comments
Closed
Assignees
Labels
area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. cherry-pick-candidate Candidates to be cherry-picked dart-cli-bug Issues related to the 'dart bug' tool type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@dcharkes
Copy link
Contributor

After 8e00ebc the following code started failing:

!Sdk.checkArtifactExists(sdk.dart)) {

sdk.dart was recently changed: from Platform.resolvedExecutable to Platform.executable. Why was it changed @bkonyi?

The error only shows up when downloading a dev build of the SDK, not when running the tests with an SDK from the out/ or xcodebuild/ directory.

I believe using Platform.resolvedExecutable should make things working again. However, I'm open to other solutions if the build command is holding things the wrong way.

@dcharkes dcharkes added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. dart-cli-bug Issues related to the 'dart bug' tool labels Jun 26, 2024
auto-submit bot pushed a commit to dart-lang/native that referenced this issue Jun 26, 2024

Verified

This commit was signed with the committer’s verified signature.
jtescher Julian Tescher
Adds Apple clang flags for compiling Objective-C with the `CBuilder`.

Issue:

* #1227

Also pins the dev CI to the latest working version:

* dart-lang/sdk#56080
@bkonyi
Copy link
Contributor

bkonyi commented Jun 26, 2024

This was changed because google3 makes heavy use of symlinks and CLI artifacts were never guaranteed to be in the same directory as the CLI executable after the symlinks were resolved. Let me take a look, hopefully this is a simple fix.

@bkonyi
Copy link
Contributor

bkonyi commented Jun 26, 2024

@dcharkes, I'm unable to reproduce at HEAD:

bkonyi@bkonyi-glinux:~/dart-sdk/sdk/third_party/pkg/native/pkgs/native_assets_cli/example/build/native_add_app$ echo $DART_RELEASE
/usr/local/google/home/bkonyi/dart-sdk/sdk/out/ReleaseX64/dart-sdk/bin/dart
bkonyi@bkonyi-glinux:~/dart-sdk/sdk/third_party/pkg/native/pkgs/native_assets_cli/example/build/native_add_app$ $DART_RELEASE --enable-experiment=native-assets build bin/native_add_app.dart 
Deleting output directory: /usr/local/google/home/bkonyi/dart-sdk/sdk/third_party/pkg/native/pkgs/native_assets_cli/example/build/native_add_app/bin/native_add_app/.
Building native assets.
Writing native_assets.yaml.
Copying 1 build assets: (package:native_add_library/native_add_library.dart)
Generated: /usr/local/google/home/bkonyi/dart-sdk/sdk/third_party/pkg/native/pkgs/native_assets_cli/example/build/native_add_app/bin/native_add_app/native_add_app.exe

Does this SDK need to be downloaded for the issue to be reproduced?

@bkonyi
Copy link
Contributor

bkonyi commented Jun 26, 2024

I'm also unable to reproduce with 3.5.0-243.0.dev downloaded from the SDK archives page.

@dcharkes
Copy link
Contributor Author

dcharkes commented Jun 26, 2024

Does this SDK need to be downloaded for the issue to be reproduced?

It's reliably reproducing on the GitHub CI downloading the SDK, see the links in the linked issue. I haven't tried locally.

@bkonyi
Copy link
Contributor

bkonyi commented Jun 26, 2024

Does this SDK need to be downloaded for the issue to be reproduced?

It's reliably reproducing on the GitHub CI downloading the SDK, see the links in the linked issue. I haven't tried locally.

Without more insights into the environment (e.g., the directory structure and contents of the unzipped SDK in the context of the GitHub CI), there's unfortunately not much we can do without a reproduction. If there's symlinks involved, that could be problematic, but checkArtifactExists should be able to follow them.

@bkonyi
Copy link
Contributor

bkonyi commented Jun 26, 2024

Hm, maybe we should be using FileSystemEntity.typeSync instead of File.existsSync, which appears like it might return false if we're checking the path to a Link object.

@dcharkes
Copy link
Contributor Author

Hm, maybe we should be using FileSystemEntity.typeSync instead of File.existsSync, which appears like it might return false if we're checking the path to a Link object.

Ah that could be the case.

The code itself that is failing is fairly simple right. Platform.executable or Platform.resolvedExecutable and then checkArtifactExists that does File(path).existsSync().

Unless someone messed with the current directory that should always be true (except for when it's a symlink as you point out).

It's worth giving it a shot. I don't know how to test this other than landing it, waiting for a dev build and turning the CI back to the latest dev build.

copybara-service bot pushed a commit that referenced this issue Jun 26, 2024
…on to Files

Related issue: #56080

Change-Id: I9b630ea3488e3f030cd92c593a4ee3bb4d718dd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373380
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
@dcharkes
Copy link
Contributor Author

dcharkes commented Jul 9, 2024

@bkonyi it seems to be still failing on 3.6.0-12.0.dev:

Run dart --enable-experiment=native-assets build bin/native_add_app.dart
  dart --enable-experiment=native-assets build bin/native_add_app.dart
  shell: /usr/bin/bash -e {0}
  env:
    DART_HOME: /opt/hostedtoolcache/dart/3.6.0-12.0.dev/x64
    PUB_CACHE: /home/runner/.pub-cache
Could not find dart. Have you built the full Dart SDK?
Error: Process completed with exit code 255.

https://github.com/dart-lang/native/actions/runs/9853109946/job/27202956400?pr=1271

So the fix unfortunately didn't work.

This was changed because google3 makes heavy use of symlinks and CLI artifacts were never guaranteed to be in the same directory as the CLI executable after the symlinks were resolved. Let me take a look, hopefully this is a simple fix.

In this case it's not a different CLI artifact, it's dart itself.

    if (!Sdk.checkArtifactExists(genKernel) ||
        !Sdk.checkArtifactExists(genSnapshot) ||
        !Sdk.checkArtifactExists(sdk.dart)) {

It's also weird that apparently it is able to find genKernel and genSnapshot.

@dcharkes
Copy link
Contributor Author

dcharkes commented Jul 9, 2024

Does this SDK need to be downloaded for the issue to be reproduced?

It's reliably reproducing on the GitHub CI downloading the SDK, see the links in the linked issue. I haven't tried locally.

Without more insights into the environment (e.g., the directory structure and contents of the unzipped SDK in the context of the GitHub CI), there's unfortunately not much we can do without a reproduction. If there's symlinks involved, that could be problematic, but checkArtifactExists should be able to follow them.

We do own the setup action: https://github.com/dart-lang/setup-dart Maybe someone who contributed to that knows how GitHub uses symlinks. cc @devoncarew

@bkonyi bkonyi added the cherry-pick-candidate Candidates to be cherry-picked label Jul 22, 2024
copybara-service bot pushed a commit that referenced this issue Jul 23, 2024
…art' when run from PATH

Fixes #56080

TEST=new test added

Change-Id: I301b6959e372c2ad8b72ce055645b5affce5516e
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/376860
Cherry-pick-request: #56303
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377140
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
copybara-service bot pushed a commit that referenced this issue Jul 24, 2024
… to find the 'dart' when run from PATH"

This reverts commit 708f487.

Reason for revert: sdk_from_path_test is failing on Windows configurations.

Original change's description:
> [beta] [ CLI ] Fix issue where 'dart build' would fail to find the 'dart' when run from PATH
>
> Fixes #56080
>
> TEST=new test added
>

Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/376860
Cherry-pick-request: #56303
Change-Id: I378f4d128674d216382e60eadc9181220ba872de
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377264
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
@bkonyi bkonyi reopened this Jul 30, 2024
@bkonyi
Copy link
Contributor

bkonyi commented Jul 30, 2024

The fix for this CL should be cherry-picked into beta/stable when the window opens again.

copybara-service bot pushed a commit that referenced this issue Aug 22, 2024
… return 'dart'

When running the VM from PATH using 'dart', Platform.executable could report
the process name as 'dart' instead of 'dart.exe'. This change updates dartdev
to handle this case so the checkArtifactExists call doesn't fail to find the
'dart' binary.

Fixes #56306

[stable] [ CLI ] Fix issue where 'dart build' would fail to find the 'dart' when run from PATH

Fixes #56080

Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/377542, https://dart-review.googlesource.com/c/sdk/+/376860
Cherry-pick-request: #56500
Change-Id: Ic30145309a307204d83353759d7b6c5da07faaa8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381041
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
@dcharkes dcharkes closed this as completed Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. cherry-pick-candidate Candidates to be cherry-picked dart-cli-bug Issues related to the 'dart bug' tool type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants