dart-lang / yaml_edit

A library for YAML manipulation with comment and whitespace preservation.
https://pub.dev/packages/yaml_edit
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

Failed yaml edit #55

Closed sigurdm closed 6 months ago

sigurdm commented 1 year ago

Reproduction:

> dart --version
Dart SDK version: 3.1.0-227.0.dev (dev) (Sun Jun 18 18:21:21 2023 -0700) on "linux_x64"
# pubspec.yaml
name: sample
version: 0.1.0
environment:
  sdk: ^3.0.0
dependencies:
dev_dependencies:
  retry:

No pubspec.lock.

dart pub add retry
"retry" was found in dev_dependencies. Removing "retry" and adding it to dependencies instead.
Assertion failed: (package:yaml_edit) Modification did not result in expected result.

# YAML before edit:
> name: sample
> version: 0.1.0
> environment:
>   sdk: ^3.0.0
> dependencies:
>   retry: ^3.1.2
> dev_dependencies:
>   retry:

# YAML after edit:
> name: sample
> version: 0.1.0
> environment:
>   sdk: ^3.0.0
> dependencies:
>   retry: ^3.1.2
> :

Please file an issue at:
https://github.com/dart-lang/yaml_edit/issues/new?labels=bug
package:yaml_edit/src/editor.dart 565:7  YamlEditor._performEdit
package:yaml_edit/src/editor.dart 432:5  YamlEditor.remove
package:pub/src/command/add.dart 722:24  AddCommand._updatePubspec
package:pub/src/command/add.dart 239:28  AddCommand.runProtected
This is an unexpected error. The full log and other details are collected in:

    /usr/local/google/home/sigurdm/.pub-cache/log/pub_log.txt

Consider creating an issue on https://github.com/dart-lang/pub/issues/new
and attaching the relevant parts of that log file.
sigurdm commented 6 months ago

@jonasfj we should look into this.

jonasfj commented 6 months ago

If the file ends immediately after retry:, instead of there being a newline this causes issues.