Skip to content
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

Fix running dart_dev in mixed-version packages opted into null safety #373

Merged
merged 6 commits into from
May 24, 2022

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented May 11, 2022

Motivation

dart_dev currently fails to run in mixed-version packages that have opted into null safety but have some non-null-safe dependencies.

This is because, in those packages, the bootstrap script is run in sound null safety mode by default, which fails because dart_dev (and potentially other packages pulled in via the config) are not themselves null-safe.

This is what those errors look like:

$ ddev format
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:dart_dev

For solutions, see https://dart.dev/go/unsound-null-safety

When using a config.dart that's also opted out of null-safety via a language comment:

$ ddev format
tool/dart_dev/config.dart:1:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:dart_dev

For solutions, see https://dart.dev/go/unsound-null-safety

Solution

  • While dart_dev is null safe, opt the run script out of null safety using a version comment (this could also be achieved via a --no-sound-null-safety flag, but this seemed more straightforward)
  • If there's a language version comment in config.dart, copy that over to the run script. This will ensure that non-null-safe configs will continue to work even after dart_dev itself is migrated to null safety,
  • Add functional tests that fail unless this new logic is in place

Testing

  • CI passes

@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@greglittlefield-wf greglittlefield-wf changed the title Fix running dart_dev in null safe packages Fix running dart_dev in mixed-version packages opted into null safety May 11, 2022
evanweible-wf
evanweible-wf previously approved these changes May 24, 2022
@evanweible-wf
Copy link
Contributor

LGTM - thanks for adding this @greglittlefield-wf! Would you mind adding a changelog entry for this? I think it makes sense as a patch, so the next version would be 3.8.4

@greglittlefield-wf
Copy link
Contributor Author

@evanweible-wf Np, thanks for reviewing! Can do!

@evanweible-wf
Copy link
Contributor

QA +1

  • CI passes

@Workiva/release-management-p

Copy link
Contributor

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@rmconsole2-wf rmconsole2-wf merged commit af28708 into master May 24, 2022
@rmconsole2-wf rmconsole2-wf deleted the fix-running-in-null-safe-package branch May 24, 2022 22:02
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.

5 participants