From e8e9b38db23c6ee45ba1218f068c98e59eb242cc Mon Sep 17 00:00:00 2001 From: chika3742 Date: Sun, 17 Nov 2024 20:23:18 +0900 Subject: [PATCH] fix(pub): update fails when project contains dependency from dart sdk Packages such as analyzer depend on macros package, which depends on _macros which is included in the Dart SDK. When the project depends on such packages, Dependabot will no longer create any PRs because it cannot find _macros package. This commit passes the DART_ROOT environment variable to dependency_services so that it can find the Dart SDK. --- pub/lib/dependabot/pub/helpers.rb | 1 + .../dependabot/pub/update_checker_spec.rb | 22 +++++++++++++++++++ .../pubspec.yaml | 8 +++++++ 3 files changed, 31 insertions(+) create mode 100644 pub/spec/fixtures/projects/can_update_with_dart_sdk_deps/pubspec.yaml diff --git a/pub/lib/dependabot/pub/helpers.rb b/pub/lib/dependabot/pub/helpers.rb index b0ffd79aec..c27b84e8de 100644 --- a/pub/lib/dependabot/pub/helpers.rb +++ b/pub/lib/dependabot/pub/helpers.rb @@ -229,6 +229,7 @@ def run_dependency_services(command, stdin_data: nil) "CI" => "true", "PUB_ENVIRONMENT" => "dependabot", "FLUTTER_ROOT" => "/tmp/flutter", + "DART_ROOT" => "/tmp/flutter/bin/cache/dart-sdk", "PUB_HOSTED_URL" => options[:pub_hosted_url], # This variable will make the solver run assuming that Dart SDK version. # TODO(sigurdm): Would be nice to have a better handle for fixing the dart sdk version. diff --git a/pub/spec/dependabot/pub/update_checker_spec.rb b/pub/spec/dependabot/pub/update_checker_spec.rb index eaf67acbf0..a77b2fcc2d 100644 --- a/pub/spec/dependabot/pub/update_checker_spec.rb +++ b/pub/spec/dependabot/pub/update_checker_spec.rb @@ -839,6 +839,28 @@ end end + context "when given a project with dependencies from dart sdk" do + let(:project) { "can_update_with_dart_sdk_deps" } + let(:dependency_name) { "lints" } + let(:requirements_to_unlock) { :all } + + it "can update lints" do + expect(can_update).to be_truthy + expect(updated_dependencies).to eq [ + { "name" => "lints", + "package_manager" => "pub", + "previous_requirements" => [{ + file: "pubspec.yaml", groups: ["dev"], requirement: "^3.0.0", source: nil + }], + "previous_version" => "3.0.0", + "requirements" => [{ + file: "pubspec.yaml", groups: ["dev"], requirement: "^4.0.0", source: nil + }], + "version" => "4.0.0" } + ] + end + end + context "when loading a YAML file with alias" do fixture = "spec/fixtures/projects/yaml_alias/" alias_info_file = "pubspec_alias_true.yaml" diff --git a/pub/spec/fixtures/projects/can_update_with_dart_sdk_deps/pubspec.yaml b/pub/spec/fixtures/projects/can_update_with_dart_sdk_deps/pubspec.yaml new file mode 100644 index 0000000000..d18bc62a97 --- /dev/null +++ b/pub/spec/fixtures/projects/can_update_with_dart_sdk_deps/pubspec.yaml @@ -0,0 +1,8 @@ +name: dependabot_testcase +environment: + sdk: ^3.5.0 +dependencies: + _macros: + sdk: dart +dev_dependencies: + lints: ^3.0.0