Sdk: CI build broken by dart2js on Dart 2.12.0-13.0.dev

Created on 4 Nov 2020  路  9Comments  路  Source: dart-lang/sdk

I just received a notification that my Travis build was broken. It looks like the failing command is:

dart2js --server-mode -Dnode=true -Dversion=1.2.3 -Ddart-version=2.12.0-13.0.dev -obuild/my_app.dart.js build/my_app_npm.dart

It's failing with this error:

Error: This project cannot run with sound null safety, because one or more project dependencies do not
support null safety:
聽 聽 聽 
聽- package:js
聽 聽 聽 
Run 'pub outdated --mode=null-safety' to determine if versions of your
dependencies supporting null safety are available.
Error: Compilation failed.

Since there hasn't been any communication on [email protected] about actions I need to take to prepare for null safety, I'm very surprised to see that enforcement of null safety has been turned on in a way that breaks my code. Also, js is an official Dart team package, so I'm surprised that null safety isn't enabled for it given that enforcement has been turned on.

In case it's relevant, the application package's SDK constraint has a lower bound of 2.7.0.

customer-dart-sass

Most helpful comment

I think Siggi's right that the issue here is that the tests are generating a pubspec without an SDK constraint. I'm testing a fix for that at https://github.com/google/dart_cli_pkg/pull/69.

All 9 comments

/cc @leafpetersen @natebosch @natebosch

At a high level, this appears like dart2js (through the CFE) inferred the entrypoint of this application (build/my_app_npm.dart) as being opted-in to null safety and as a result the compiler defaults to sound-null-safety.

We were however not expecting this to trigger and need to investigate why it's happening. I haven't had a chance to replicate the issue locally, but I wonder whether the way sass uses grinder may be affecting dart2js (e.g. maybe we can't locate the package_config.json file?)

@nex3 - Not ideal, but a short workaround may be to pass --no-sound-null-safety on the commandline to dart2js.

It looks to me like dart2js has some magic behavior if the directory is specifically named build/. If try this I see that it wants to read files like build/packages/js (which doesn't exist in my example) it's not reading .packages or .dart_tool/package_config.json at all. If I rename the directory from build/ to something/ then the compile works.

@sigmundch do we have legacy behavior around build/ and build/packages?

@natebosch can you share how you were able to reproduce that. I haven't been able to create the same issue locally.

@nex3 - I tried cloning dart_cli_pkg and running the test locally with the same dev release. Even though dart_cli_pkg has an sdk constraint, it generates a sample pubspec that doesn't.
So when I run:

> xvfb-run -s "-screen 0 1024x768x24" pub run test/testing_test.dart

I get the error you posted above:

Process `pub run grinder pkg-npm-dev` exited with exitCode 1. Output:
    grinder running pkg-js-dev pkg-npm-dev

    pkg-js-dev
      /usr/local/google/home/sigmund/dart/sdk/dart-sdk/bin/dart2js --server-mode -Dnode=true -Dversion=1.2.3 -Ddart-version=2.12.0-13.0.dev -obuild/my_app.dart.js
build/my_app_npm.dart
      Error: This project cannot run with sound null safety, because one or more project dependencies do not
      support null safety:

       - package:js

      Run 'pub outdated --mode=null-safety' to determine if versions of your
      dependencies supporting null safety are available.
      Error: Compilation failed.

Adding a new line to the pubspec:

  "environment": {"sdk": ">= 2.7.0"},

Fixes this test for me.

*Note: with the latest dev release, I see a similar failure but with the name of many other packages on many tests (including pkg-standalone-dev, etc)

@natebosch @leafpetersen - is the intent that when we don't have a lowerbound in the pubspec, we'll automatically opt-in to null-safety? I fear that can trip many users.

/cc @jonasfj @mit-mit

Just reading the cross-reference bug, I came across a proposal to require specifying an sdk constraint (https://github.com/dart-lang/pub/issues/2707#issuecomment-720599514). That would address my concern here.

is the intent that when we don't have a lowerbound in the pubspec, we'll automatically opt-in to null-safety? I fear that can trip many users.

Yes. That is the intent, and we are working on a warning an error in pub get if you are missing a lower bound SDK constraint to mitigate this pain.

can you share how you were able to reproduce that. I haven't been able to create the same issue locally.

I created an empty project with one dependency and one app under a directory named build/ that imports it. Then I ran dart2js with no arguments other than the input and output filenames and saw a failure. Next I copied the app to a different directory name and ran dart2js with no errors.

I'm on Dart version 2.12.0-0.0.dev.

I created an empty project with one dependency and one app under a directory named build/ that imports it. Then I ran dart2js with no arguments other than the input and output filenames and saw a failure. Next I copied the app to a different directory name and ran dart2js with no errors.

So you have 2 pubspecs, one for the app and one for the dependency? What do those pubspecs look like?

Ah, I figured out what was going on. There was a build/.packages file that I had forgotten existed.

@nex3 - what other files are in your build/?

I think Siggi's right that the issue here is that the tests are generating a pubspec without an SDK constraint. I'm testing a fix for that at https://github.com/google/dart_cli_pkg/pull/69.

Looks like that did the trick!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DartBot picture DartBot  路  3Comments

matanlurey picture matanlurey  路  3Comments

DartBot picture DartBot  路  3Comments

xster picture xster  路  3Comments

Hixie picture Hixie  路  3Comments