Cannot find referenced source: package:mongo_dart/mongo_dart.dart

390 views
Skip to first unread message

Samer Ali

unread,
Oct 31, 2012, 10:07:33 AM10/31/12
to mi...@dartlang.org
Hello,

I have this pubspec.yaml

name: Woven Pages
description: The Woven platform.
dependencies:
  web_components: any
  mongo_dart: any

then i run Tools > Pub Install, the operation completes successively.

now on the editor i get this: http://screencast.com/t/327egelXrMTi

When i run the application i get the following error: 
dart --enable-checked-mode web\page.dart

Unable to open file: C:/Users/Samer/Documents/GitHub/woven/web/packages/mongo_dart/mongo_dart.dart'file:///C:/Users/Samer/Documents/GitHub/woven/web/page.dart': Error: line 1 pos 1: library handler failed
#import("package:mongo_dart/mongo_dart.dart");


David Notik

unread,
Oct 31, 2012, 2:31:23 PM10/31/12
to mi...@dartlang.org
I had a similar issue.  In other words, no libraries/packages are being found.

IIRC, I had to do set some system paths or something.  Perhaps someone else can help?

Thank you!

--D

Keerti Parthasarathy

unread,
Oct 31, 2012, 3:21:04 PM10/31/12
to General Dart Discussion
In the editor, do a Tools > Reanalyze sources and see if that clears the errors. Also, check if the packages were installed and that you are able to open mango_dart.dart in the editor.


--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 



--
Keerti

Samer Ali

unread,
Oct 31, 2012, 6:30:50 PM10/31/12
to mi...@dartlang.org
Thankyou Keerti,

Ok I tried "Reanalyze sources", "Organize Resources", "Pub Update", "Pub Install", still have the same error message.

When i try to open mango_dart.dart (the folder is empty), and same for the other packages as well. Any idea what could be the problem?

Thanks!

Keerti Parthasarathy

unread,
Oct 31, 2012, 11:10:53 PM10/31/12
to General Dart Discussion
Well, here is what might have happened  The editor does not handle symlinks too well on the Windows platform. If you use the editor to delete the packages directory for any of the libraries, it not only deletes the link but also follows the link and deletes the contents in the pub cache. This is very unfortunate, we are aware of this issue (dartbug.com/5583) and hope to fix this as soon as possible. 

In the meantime, in order to get it all working again you can do the following. Delete the system package cache, the .pub-cache subdirectory in your home directory. Then run pub install and it will do a fresh install of all the necessary packages. 
Message has been deleted

Eduardo Ferrari Copat

unread,
Oct 31, 2012, 11:51:11 PM10/31/12
to mi...@dartlang.org
I had the same problem, my solution was the to change ':' to '/'

import("package:mongo_dart/mongo_dart.dart");

to

 #import("package/mongo_dart/mongo_dart.dart");

Or try:
 
import 'packages/mongo_dart/mongo_dart.dart' as js;


Vadim Tsushko

unread,
Nov 1, 2012, 4:16:56 AM11/1/12
to mi...@dartlang.org
Unrelated to question proper - I would recommend for time being reference mongo_dart not from pub.dartlang.org but from git repository.
I.e. change your dependency to:


Currently pub.dartlang.org is updated manually by google employees. There is some delays, so for example version of mongo_dart frm pub.dartlang.org is broken with respect to current sdk (Dart Editor version 0.2.1_r14167 Dart SDK version 0.2.1.2_r14167).
Things certainly will improve when it would be possible update pub.dartlang.org repositories for authors themself. 
Meantime I would recommend old way.

Best regards, Vadim Tsushko


среда, 31 октября 2012 г., 20:07:33 UTC+6 пользователь Samer Ali написал:

Bob Nystrom

unread,
Nov 1, 2012, 1:56:41 PM11/1/12
to mi...@dartlang.org
On Wed, Oct 31, 2012 at 8:51 PM, Eduardo Ferrari Copat <eco...@gmail.com> wrote:
I had the same problem, my solution was the to change ':' to '/'

import("package:mongo_dart/mongo_dart.dart");

to

 #import("package/mongo_dart/mongo_dart.dart");

Or try:
 
import 'packages/mongo_dart/mongo_dart.dart' as js;

Please do not do this. It does coincidentally work in some cases, but not in others. Consider this:

foo/
  bin/
    main.dart -> import 'packages/foo/foo.dart';
  lib/
    foo.dart -> import 'packages/foo/bar.dart';
    bar.dart

The first import in main.dart will work because "bin" has a "packages" directory. But the import of "packages/foo/bar.dart" will not work because "lib" does not. There are similar problems with transitive imports across packages.

It's definitely confusing and non-obvious, but you really do need to use "package:" in order for stuff to be happy.

Cheers!
- bob


 


 

Em quarta-feira, 31 de outubro de 2012 12h07min33s UTC-2, Samer Ali escreveu:
Hello,

I have this pubspec.yaml

name: Woven Pages
description: The Woven platform.
dependencies:
  web_components: any
  mongo_dart: any

then i run Tools > Pub Install, the operation completes successively.

now on the editor i get this: http://screencast.com/t/327egelXrMTi

When i run the application i get the following error: 
dart --enable-checked-mode web\page.dart

Unable to open file: C:/Users/Samer/Documents/GitHub/woven/web/packages/mongo_dart/mongo_dart.dart'file:///C:/Users/Samer/Documents/GitHub/woven/web/page.dart': Error: line 1 pos 1: library handler failed
#import("package:mongo_dart/mongo_dart.dart");


Samer Ali

unread,
Nov 5, 2012, 8:39:56 AM11/5/12
to mi...@dartlang.org
I was Able to resolve that issues by going to my user profile

at C:\Users\USERNAME\AppData\Roaming and delete the folder Pub from there.

restart the editor and run pub install/update.


On Wednesday, October 31, 2012 10:07:33 AM UTC-4, Samer Ali wrote:

Bob Nystrom

unread,
Nov 5, 2012, 5:07:06 PM11/5/12
to mi...@dartlang.org
On Mon, Nov 5, 2012 at 5:39 AM, Samer Ali <sa...@sameronline.com> wrote:
I was Able to resolve that issues by going to my user profile

at C:\Users\USERNAME\AppData\Roaming and delete the folder Pub from there.

I'm glad that fixed your issue. Can you let us know if you run into this problem again? I've added some code to pub that should avoid needing to do this, and I'd like to make sure that actually addresses the problems.

Thanks!

- bob

Samer Ali

unread,
Nov 5, 2012, 9:18:47 PM11/5/12
to mi...@dartlang.org
Bob, i don't think i had this issue again no, but i think the main reason that it happens when you delete the packages folder/shortcut manually from the project folders.

Thanks for your support, if you have any other questions let me know!


Thomas Stephenson

unread,
Feb 2, 2013, 7:32:12 AM2/2/13
to mi...@dartlang.org
I was having a similar issue. One of the files that was 'part of' a library I was developing was not recognising the fact that I'd imported the google_maps package from the top level. 

I tried the %APPDATA% fix, but it didn't work. However, renaming the module did. Renaming it back to the original filename was OK too. I suspect that the problem I have concerns only the dart editor , because I had no problems compiling and running an app which imports it, but I can't give you any more information than that

Enjoy,
Thomas
Message has been deleted

Thomas Stephenson

unread,
Feb 2, 2013, 8:00:18 AM2/2/13
to mi...@dartlang.org
Strike that -- the dart editor just spat the dummy, I was not getting any errors/warnings from it, so it looked like my file was ok for a while. After renaming the file *again*, the problem has come back. 

Are packages supposed to be visible from a lib/ directory or not? It causes no warnings errors when I import it from the library file, but the module isn't visible from in any of the part's namespaces.

Thomas

Bob Nystrom

unread,
Feb 4, 2013, 3:59:04 PM2/4/13
to General Dart Discussion

On Sat, Feb 2, 2013 at 5:00 AM, Thomas Stephenson <ova...@gmail.com> wrote:
Are packages supposed to be visible from a lib/ directory or not? It causes no warnings errors when I import it from the library file, but the module isn't visible from in any of the part's namespaces.

You can use "package:" imports inside Dart that lives under lib/. However, you can not have Dart entrypoints (libraries that have a main()) inside lib/. Those need to be in bin/, example/, test/, tool/, or web/.

Does that make sense?

- bob
Reply all
Reply to author
Forward
0 new messages