nyxx-discord / nyxx

Wrapper around Discord API for Dart
Apache License 2.0
326 stars 49 forks source link

Compilation error: "Unrecognized flags: null-safety" #98

Closed Fuwn closed 4 years ago

Fuwn commented 4 years ago

Describe the bug During the process of attempting to build, run, anything, I get a slew of errors;

Open here.

```sh fuwn > dart run /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:24:3: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. Try adding the name of the type of the variable or the keyword 'var'. late final ClientOptions _options; ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:24:3: Error: Expected ';' after this. late final ClientOptions _options; ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:25:3: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. Try adding the name of the type of the variable or the keyword 'var'. late final _ConnectionManager _ws; // ignore: unused_field ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:25:3: Error: Expected ';' after this. late final _ConnectionManager _ws; // ignore: unused_field ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:25:3: Error: 'late' is already declared in this scope. late final _ConnectionManager _ws; // ignore: unused_field ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:24:3: Context: Previous declaration of 'late'. late final ClientOptions _options; ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:26:3: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. Try adding the name of the type of the variable or the keyword 'var'. late final _EventController _events; ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:26:3: Error: Expected ';' after this. late final _EventController _events; ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:26:3: Error: 'late' is already declared in this scope. late final _EventController _events; ^^^^ /C:/Users/Fuwn/AppData/Local/Pub/Cache/git/nyxx-742a6773663b3dba93ff8fb9c465641c803b3c25/nyxx/lib/src/Nyxx.dart:25:3: Context: Previous declaration of 'late'. late final _ConnectionManager _ws; // ignore: unused_field ^^^^ ```

As well, following the wiki, I tried to run; fuwn > dart --enable-experiment=non-nullable --no-null-safety bin/nyxx-test.dart But that renders me the Setting VM flags failed: Unrecognized flags: null-safety error.

To Reproduce Attempt 1. dart run Attempt 2. dart compile ... Attempt 3. fuwn > dart --enable-experiment=non-nullable --no-null-safety bin/nyxx-test.dart

Expected behavior I'd assume that it would let me run the bot.

Desktop (please complete the following information):

Additional context I'm using the Dart SDK edition which comes pre-packaged with the Flutter SDK.

l7ssha commented 4 years ago

Thats not nyxx error, but problem with sdk - sdk 2.10 doesn't have --no-null-safety flag. Nyxx support max sdk 2.9.x because Dart 2.10 requires all dependencies to be compatibile with nnbd. If you want to use sdk >2.10 you can use 1.1 branch from repo it supports higher versions of sdk.

Fuwn commented 4 years ago

Completely skipped over that, thanks for the quick reply!

l7ssha commented 4 years ago

I pinned this issue, because it's returning problem. Transition between nnbd is quite awful and there is nothing I can do. Next release of nyxx will be for sdk 2.12 which will have enabled nnbd by default so that wouldn't be a problem anymore.

nathanfranke commented 4 years ago

You can use the 1.1 branch without forking! Add these to your pubspec.yaml:

dependencies: 
  nyxx: "^1.1.0"
dependency_overrides:
  nyxx:
    git:
      url: https://github.com/l7ssha/nyxx.git
      ref: "1.1"
      path: nyxx
  http:
    git:
      url: git://github.com/dart-lang/http.git
  logging:
    git:
      url: git://github.com/dart-lang/logging.git
  http_parser:
    git:
      url: git://github.com/dart-lang/http_parser.git

For commander, add these too:

dependencies: 
  nyxx_commander: "^1.0.1"
dependency_overrides:
  nyxx_commander:
    git:
      url: https://github.com/l7ssha/nyxx.git
      ref: "1.1"
      path: nyxx.commander
phibr0 commented 3 years ago

You can use the 1.1 branch without forking! Add these to your pubspec.yaml:

dependencies: 
  nyxx: "^1.1.0"
dependency_overrides:
  nyxx:
    git:
      url: https://github.com/l7ssha/nyxx.git
      ref: "1.1"
      path: nyxx
  http:
    git:
      url: git://github.com/dart-lang/http.git
  logging:
    git:
      url: git://github.com/dart-lang/logging.git
  http_parser:
    git:
      url: git://github.com/dart-lang/http_parser.git

For commander, add these too:

dependencies: 
  nyxx_commander: "^1.0.1"
dependency_overrides:
  nyxx_commander:
    git:
      url: https://github.com/l7ssha/nyxx.git
      ref: "1.1"
      path: nyxx.commander

If I use this Solution my Bot goes online but nothing happens if it receives a message. After a minute or so i get the following error in the console:

[WARNING] [Shard Manager] Not received previous heartback ack

My Code:

import 'package:nyxx/nyxx.dart';

void main(List<String> arguments) {
  var bot =
      Nyxx('SECRET_TOKEN', 8);

  bot.onReady.listen((event) {
    print('Ready');
  });

  bot.onMessageReceived.listen((event) {
    print(event.message);
  });
}
l7ssha commented 3 years ago

@phibr0 your problem is not in scope of this issue. Please open new issue with full code, full pubspec and full console output. and warning you posting isnt error of any sort, just notice that client hasnt received heartbeat ack which isn't a problem.

l7ssha commented 3 years ago

Prerelease version of Dart 1.1 is now available in pub: https://pub.dev/packages/nyxx/versions/1.1.0-dev.1. It requires dev sdk 2.12