Dart import packages not working

强颜欢笑 提交于 2019-12-24 01:59:08

问题


Having an issue with importing packages in Dart now, the project was working yesterday but has stopped today and I have no clue why, the code hasn't changed all weekend and I don't recall running any updates. The problem exists with anything with the "package:" url. For example both of these are broken in my project:

import 'package:args/args.dart';
import 'package:crypto/crypto.dart';

The error message for these is:

Unhandled exception:
Uncaught Error: FileSystemException: Cannot open file, path = 'D:\Dart\server\bin\packages\args\args.dart' (OS Error: The system cannot find the file specified. , errno = 2)
Stack Trace:
#0      _File.open.<anonymous closure> (dart:io/file_impl.dart:349)
#1      _RootZone.runUnary (dart:async/zone.dart:1151)
#2      _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:496)
#3      _Future._propagateToListeners (dart:async/future_impl.dart:579)
#4      _Future._completeWithValue (dart:async/future_impl.dart:339)
#5      _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:401)
#6      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#7      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#8      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)

#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:883)
#1      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)

These are in my pubspec.yaml:

name: server
description: A Server
dependencies:
  args: ">=0.12.1 <0.13.0"
  crypto: ">=0.9.0 <0.10.0"
  io: ">=0.1.0-git <0.2.0"

And pub get (and pub upgrade) runs successfully:

"D:\Program Files\dart\dart-sdk\bin\pub.bat" upgrade
Resolving dependencies...
  args 0.12.1
  collection 1.1.0
  crypto 0.9.0
  io 0.1.0-git
No dependencies changed.
Process finished with exit code 0

Creating a brand new project and copying the code over yields the same issue. I've also tried deleting all project packages directories and the pubspec.lock file and re-running pub get, again, no luck although it successfully retrieves the packages.

The packages directories do seem to be empty though, just a bunch of shortcuts that end up in empty directories when you drill down in the windows file system?

Running out of ideas and it's critical to development of the client application. Any ideas would be much appreciated!


回答1:


I'm pretty sure you can solve this with pub cache repair (execute on the command line) or alternatively delete the pub cache directory.



来源:https://stackoverflow.com/questions/26842778/dart-import-packages-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!