Dart import packages not working
Asked Answered
S

1

6

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!

Succussion answered 10/11, 2014 at 11:28 Comment(1)
See also stackoverflow.com/questions/26809192 (I don't imply that this has to do with CDE though). See also comments to plus.google.com/113415344870093527255/posts/Tab8xQnqoFsWhitacre
D
11

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

Darleen answered 10/11, 2014 at 11:31 Comment(2)
Thanks! That was quick! Will accept in 10 minutes when it lets me as it works perfectly.Succussion
I had the same problem. In addition to cache repair. I had to restart my computer for my imports to work again.Eadie

© 2022 - 2024 — McMap. All rights reserved.