conduit-dart / conduit

Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.
https://theconduit.dev
BSD 2-Clause "Simplified" License
450 stars 43 forks source link

[BUG]conduit build fail with not found CodeAnalyzer #198

Closed delphi007 closed 1 year ago

delphi007 commented 1 year ago

Describe the bug conduit build fail

To Reproduce Steps to reproduce the behavior:

  1. cd
  2. dart pub get
  3. conduit build
  4. See error -- Conduit CLI Version: 4.3.9 -- Conduit project version: 4.3.8 Starting build process... Resolving ASTs... Generating runtime... Generated runtime at 'file:///tmp/build/generated_runtime/'. Compiling package 'conduit_runtime'... Package 'conduit_runtime' compiled to 'file:///tmp/build/packages/conduit_runtime/'. Compiling package 'conduit_core'... Package 'conduit_core' compiled to 'file:///tmp/build/packages/conduit_core/'. Compiling package 'conduit_config'... Package 'conduit_config' compiled to 'file:///tmp/build/packages/conduit_config/'. Copying application package (from 'file:///Users/delphi/workdir/vda_auto_server/')... Application packaged copied to 'file:///tmp/build/packages/vda_auto_server/'. Fetching dependencies (--offline --no-precompile)... Finished fetching dependencies. Compiling... *** Uncaught error Bad state: Bad state: 'dart2native' failed with the following message: Info: Compiling with sound null safety. /Users/delphi/.pub-cache/hosted/pub.flutter-io.cn/conduit-4.3.9/lib/src/migration_source.dart:21:22: Error: Method not found: 'CodeAnalyzer'. final analyzer = CodeAnalyzer(uri); Error: AOT compilation failed Generating AOT kernel dill failed!

    0 generateNative (package:dart2native/generate.dart:72:7)

    #1 CompileNativeCommand.run (package:dartdev/src/commands/compile.dart:312:7) #2 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #3 DartdevRunner.runCommand (package:dartdev/dartdev.dart:241:18) #4 runDartdev (package:dartdev/dartdev.dart:65:18) #5 main (file:///opt/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:3) **** Stacktrace * #0 Build.compile (package:conduit_runtime/src/build.dart:161:7) * * #1 Build.execute (package:conduit_runtime/src/build.dart:121:7) * * #2 BuildExecutable.execute (:13:240) * * #3 main (:9:18) * ****

Expected behavior build success

Analysis Actually this is not what my project error but conduit. Have checked pub_cache, the conduit_runtime/4.3.7 exist which include the CodeAnalyzer class definition.

System Information:

pst9354 commented 1 year ago

I have the same problem here. Using conduit 4.3.6 Dart 2.19.4 Debian

j4qfrost commented 1 year ago

@delphi007 @pst9354 can you both try purging all the conduit packages from pub cache and try rerunning conduit build?

pst9354 commented 1 year ago

Same error after cleaning cache.

j4qfrost commented 1 year ago

This might be an issue "hosted/pub.flutter-io.cn" @pst9354 what location are you using for your cache?

pst9354 commented 1 year ago

taxiteknik@vps-NPvKz:~/.pub-cache$ ls -l hosted total 4 drwxr-xr-x 93 taxiteknik taxiteknik 4096 Mar 15 15:23 pub.dev

delphi007 commented 1 year ago

@j4qfrost After 'rm -rf conduit' in hosted/pub.flutter-io.cn and 'dart pub get' , I got the same error from 'conduit build'. Then I switched the pub repository back to pub.dev, remove 'conduit', rerun 'dart pub get & conduit build', the same error.

Btw, the version of each conduit package is in the picture. From the 'conduit build' output , Conduit Cli is 4.3.9, Conduit Project version is 4.3.8, although I specified the project the conduit plugin version 4.3.9 in pubspec.yaml. Just FYI.

image
youfameifa commented 1 year ago
image

add this code import 'package:conduit_runtime/src/analyzer.dart';

delphi007 commented 1 year ago

@youfameifa this perfectly solve the problem. @j4qfrost Would it be possible to add this line in migration_source.dart for the next release?