aqueduct
aqueduct copied to clipboard
aqueduct create error: bad state
Hi! I recently installed aqueduct but i couldn't get it to work it... It gives error on the "aqueduct create" command. pub 2.9.1 dart 2.9.1
stack trace `-- Aqueduct CLI Version: 3.3.0+1 *** Uncaught error Bad state: No element **** Stacktrace
- #0 ListMixin.firstWhere (dart:collection/list.dart:148:5)
- #1 CLIAqueductGlobal.aqueductPackageRef (package:aqueduct/src/cli/commands/create.dart:342:10)
- #2 CLIAqueductGlobal.templateDirectory (package:aqueduct/src/cli/commands/create.dart:347:12)
- #3 CLIAqueductGlobal.getTemplateLocation (package:aqueduct/src/cli/commands/create.dart:351:12)
- #4 CLITemplateCreator.handle (package:aqueduct/src/cli/commands/create.dart:51:27)
- #5 CLICommand.process (package:aqueduct/src/cli/command.dart:159:20)
-
- #6 CLICommand.process (package:aqueduct/src/cli/command.dart:135:12)
- #7 main (file:///C:/Users/Ruy/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/aqueduct-3.3.0+1/bin/aqueduct.dart:9:27)
- #8 _startIsolate.
(dart:isolate-patch/isolate_patch.dart:299:32) - #9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)`
So, inspecting further, the package PUB_CACHE is searching for the pub cache folder in the "
As I understand of the local and roaming folders, shouldn't the pub cache be on local always anyways? Anyway, I just copied the pub cache folder to the roaming folder and the "aqueduct create" command worked with an asterisk: "Can't load Kernel binary: Invalid SDK hash."
Found a more permanent solution, (windows user btw). Create an ambient variable called "PUB_CACHE" with the value "%LOCALAPPDATA%\Pub\Cache" or the folder that the pub cache is in.
The reason that it may be broken for me is that i just download the dart sdk and register on path, not installed using chocolatey... maybe through choco you dont get this error.
I just encountered the exact same issue - same error, installing on windows, installed from zip and added path manually Your solution @rdnobrega worked perfectly.
Does chocolately automatically configure this env var?
Hi @sdxv ! I'm glad it worked! I think this is an issue specific from the pub_cache package. It is related to the way they search for the pub folder in the computer. First, it checks for the PUB_CACHE env var and, if it is not present, it searches for Platform.enviroment['APPDATA'] , which returns the ROAMING folder, instead of the LOCAL folder. The correct would be Platform.enviroment['LOCALAPPDATA']. My guess is that when the package was written, 'APPDATA' was refering to local, and now Dart SDK changed this key to refers to roaming and create a new 'LOCALAPPDATA' to refer to local. You can check the code here: https://github.com/google/pub_cache/blob/master/lib/pub_cache.dart at line 22.
Of course, the really best would be the package to just check if any of the folders (roaming, local, %PUB_CACHE%) exisits AND is indeed a valid pub folder, which does not occur.
Hello I don't know where that problem is But I also used to suffer from it, but the solution is simple. You must delete dart version 2.9.1 and go back to version 2.7.1. This is the solution that worked for me. I know that it is a stupid solution and I do not know the reason for that. I searched a lot until I was bored.