melos icon indicating copy to clipboard operation
melos copied to clipboard

fix: melos bootstrap throws an expected node content exception

Open samdeane opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Version

5.3.0

Description

I have a working project containing a couple of apps, and some existing internal packages.

I've now added a native flutter plugin package to it locally.

The plugin was created by: flutter create --org games.formation --template=plugin --platforms=android,ios,macos -a kotlin -i swift velocity_native and is virtually unmodified from that template.

Running melos bootstrap works fine if I don't reference the package from any other packages' pubspecs.

It also works fine if I add the package as a dependency to the pubspec of one of the applications.

However, if I add it as a dependency to the pubspec of one of my other internal packages:

name: velocity_flutter
description: Velocity engine flutter integration.
version: 1.0.0
publish_to: none

environment:
  sdk: '>=3.3.1 <4.0.0'
  flutter: '>=3.19.3 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  velocity_native: ^1.0.0.  # <-- added this here
  velocity: ^1.0.0
  velocity_generation: ^1.0.0

# (more pubspec here, removed for brevity)

the following exception is thrown when running melos bootstrap:

> dart run melos bootstrap                                                                                                                      (issues/TEC-1540-native-velocity-plugin)
melos bootstrap
  â””> /Users/sam/Developer/Projects/mono/client

Running "flutter pub get" in workspace packages...
  ✓ club
    â””> club
  ✓ club_proto
    â””> proto
  ✓ club_resource
    â””> resource
  ✓ club_view
    â””> view
  ✓ dev_server
    â””> dev_server
  ✓ testbed
    â””> testbed
  ✓ velocity
    â””> velocity
Unhandled exception:
Error on line 17, column 3: Expected node content.
   â•·
17 │   , velocity_native: {path: ../velocity_native}}
   │   ^
   ╵
#0      Parser._parseNode (package:yaml/src/parser.dart:353:5)
#1      Parser._parseFlowMappingKey (package:yaml/src/parser.dart:630:16)
#2      Parser._stateMachine (package:yaml/src/parser.dart:116:16)
#3      Parser.parse (package:yaml/src/parser.dart:61:19)
#4      Loader._loadMapping (package:yaml/src/loader.dart:175:23)
#5      Loader._loadNode (package:yaml/src/loader.dart:92:16)
#6      Loader._loadMapping (package:yaml/src/loader.dart:169:19)
#7      Loader._loadNode (package:yaml/src/loader.dart:92:16)
#8      Loader._loadDocument (package:yaml/src/loader.dart:68:20)
#9      Loader.load (package:yaml/src/loader.dart:60:20)
#10     loadYamlDocument (package:yaml/yaml.dart:72:25)
#11     loadYamlNode (package:yaml/yaml.dart:57:5)
#12     YamlEditor._performEdit (package:yaml_edit/src/editor.dart:576:24)
#13     YamlEditor.update (package:yaml_edit/src/editor.dart:271:14)
#14     mergeMelosPubspecOverrides (package:melos/src/commands/bootstrap.dart:556:34)
#15     _BootstrapMixin._generatePubspecOverrides (package:melos/src/commands/bootstrap.dart:172:45)
<asynchronous suspension>
#16     _BootstrapMixin._linkPackagesWithPubspecOverrides.<anonymous closure> (package:melos/src/commands/bootstrap.dart:109:9)
<asynchronous suspension>
#17     StreamUtils.parallel.<anonymous closure> (package:melos/src/common/utils.dart:674:18)
<asynchronous suspension>
#18     Future.any.onValue (dart:async/future.dart:608:5)
<asynchronous suspension>

Steps to reproduce

I don't currently have a repro case which doesn't involve our code - which I can't share.

Expected behavior

melos should complete normally:

> dart run melos bootstrap                                                                                                                      (issues/TEC-1540-native-velocity-plugin)
melos bootstrap
  â””> /Users/sam/Developer/Projects/mono/client

Running "flutter pub get" in workspace packages...
  ✓ club
    â””> club
  ✓ club_proto
    â””> proto
  ✓ club_resource
    â””> resource
  ✓ club_view
    â””> view
  ✓ dev_server
    â””> dev_server
  ✓ testbed
    â””> testbed
  ✓ velocity
    â””> velocity
  ✓ velocity_flutter
    â””> velocity_flutter
  ✓ velocity_generation
    â””> velocity_generation
  ✓ velocity_native
    â””> velocity_native
  ✓ velocity_test
    â””> velocity_test
  > SUCCESS

 -> 11 packages bootstrapped

Screenshots

No response

Additional context and comments

No response

samdeane avatar Apr 11 '24 10:04 samdeane

Update: manually deleting the previous pubspec_overrides.yaml file in the velocity_flutter package seems to fix this problem.

The old file was using flow-stye YAML. The new file isn't:

image

samdeane avatar Apr 11 '24 11:04 samdeane

It looks like your version accidentally ends in a dot? ^1.0.0., can you try removing the last dot and re-run bootstrap?

spydon avatar Apr 11 '24 11:04 spydon

Ah - I think that must be an artefact of my copying & pasting into this bug report. I have linting on in vscode and I think I would have spotted the warning: image

That said, I tried putting the extra dot back and running bootstrap, and it coped!

samdeane avatar Apr 11 '24 11:04 samdeane

Update: manually deleting the previous pubspec_overrides.yaml file in the velocity_flutter package seems to fix this problem.

Very odd that it was generating that before, this can be closed now then I guess? I think running melos clean && melos bootstrap should also have solved it.

spydon avatar Apr 11 '24 12:04 spydon