Skip to content

Commit

Permalink
fix(pub): update fails when project contains dependency from dart sdk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chika3742 authored and sachin-sandhu committed Nov 19, 2024
1 parent 1dc68ee commit e8e9b38
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions pub/lib/dependabot/pub/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions pub/spec/dependabot/pub/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: dependabot_testcase
environment:
sdk: ^3.5.0
dependencies:
_macros:
sdk: dart
dev_dependencies:
lints: ^3.0.0

0 comments on commit e8e9b38

Please sign in to comment.