Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Cannot serve application with angular.dart 0.13 #1270

Closed
cinan opened this issue Jul 28, 2014 · 18 comments
Closed

Cannot serve application with angular.dart 0.13 #1270

cinan opened this issue Jul 28, 2014 · 18 comments

Comments

@cinan
Copy link

cinan commented Jul 28, 2014

Hello,
today I've upgraded to angular.dart 0.13. I cannot serve my application because of "Illegal argument(s): sdkDirectory must be provided." error which occures after running "pub serve". My pubspec.yaml:

name: test_app
version: 0.0.1
dependencies:
  angular: ">=0.13.0 <0.14.0"
  browser: any
  js: any
  shadow_dom: any
  json_object: any
  crypto: any
  dart_config: any
dev_dependencies:
  unittest: ">=0.11.0 <0.12.0"
  mock: ">=0.11.0 <0.12.0"
transformers:
- angular:
    html_files:
    - web/index.html
    - web/views/login.html
    - web/views/in.html
    - web/views/profile.html
    - web/views/feedbacks.html
@taisph
Copy link
Contributor

taisph commented Jul 29, 2014

I can't reproduce the error here. What version of the dart-sdk are you using?

Also, shadow_dom has been replaced by web_components. Depending on shadow_dom may prevent certain dependencies from updating. See http://pub.dartlang.org/packages/shadow_dom

@cinan
Copy link
Author

cinan commented Jul 29, 2014

I'm using dart-sdk 1.5.3.

I replaced shadow_dom with web_components, did pub upgrade, but the problem persists.

Here's complete output of pub serve:

Loading source assets... 
Loading di/module_transformer transformers... (1.1s)
Loading angular transformers... 
Illegal argument(s): sdkDirectory must be provided.
http://127.0.0.1:58667/packages/di/transformer/options.dart 47:11    TransformOptions.TransformOptions
http://127.0.0.1:58667/packages/angular/transformer.dart 52:23       _parseSettings
http://127.0.0.1:58667/packages/angular/transformer.dart 30:28       AngularTransformerGroup.AngularTransformerGroup.asPlugin
dart:mirrors-patch/mirrors_impl.dart 760                             _LocalClassMirror.newInstance
http://127.0.0.1:58667/packages/$pub/transformer_isolate.dart 72:37  _initialize.loadFromLibrary.<fn>
dart:_internal/iterable.dart 370                                     MappedIterator.moveNext
dart:_internal/iterable.dart 415                                     WhereIterator.moveNext
dart:core-patch/growable_array.dart 173                              List.addAll
http://127.0.0.1:58667/packages/$pub/transformer_isolate.dart 54:24  _initialize.loadFromLibrary
http://127.0.0.1:58667/packages/$pub/transformer_isolate.dart 77:18  _initialize
http://127.0.0.1:58667/packages/$pub/transformer_isolate.dart 24:25  loadTransformers.<fn>.<fn>
http://127.0.0.1:58667/packages/$pub/serialize.dart 92:33            respond.<fn>
dart:async/future.dart 168                                           Future.Future.sync
http://127.0.0.1:58667/packages/$pub/serialize.dart 92:7             respond
http://127.0.0.1:58667/packages/$pub/transformer_isolate.dart 20:12  loadTransformers.<fn>
dart:async/zone.dart 730                              

pub --trace 'serve' output:

MSG : Loading angular transformers... (0.9s)
FINE: Clean up system cache temp directory /home/cinan/.pub-cache/_temp.
ERR : Illegal argument(s): sdkDirectory must be provided.
    | http://127.0.0.1:54296/packages/di/transformer/options.dart 47:11    TransformOptions.TransformOptions
    | http://127.0.0.1:54296/packages/angular/transformer.dart 52:23       _parseSettings
    | http://127.0.0.1:54296/packages/angular/transformer.dart 30:28       AngularTransformerGroup.AngularTransformerGroup.asPlugin
    | dart:mirrors-patch/mirrors_impl.dart 760                             _LocalClassMirror.newInstance
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 72:37  _initialize.loadFromLibrary.<fn>
    | dart:_internal/iterable.dart 370                                     MappedIterator.moveNext
    | dart:_internal/iterable.dart 415                                     WhereIterator.moveNext
    | dart:core-patch/growable_array.dart 173                              List.addAll
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 54:24  _initialize.loadFromLibrary
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 77:18  _initialize
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 24:25  loadTransformers.<fn>.<fn>
    | http://127.0.0.1:54296/packages/$pub/serialize.dart 92:33            respond.<fn>
    | dart:async/future.dart 168                                           Future.Future.sync
    | http://127.0.0.1:54296/packages/$pub/serialize.dart 92:7             respond
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 20:12  loadTransformers.<fn>
    | dart:async/zone.dart 730                                             _rootRunUnary
    | dart:async/zone.dart 864                                             _RootZone.runUnary
    | dart:async/future_impl.dart 488                                      _Future._propagateToListeners.handleValueCallback
    | dart:async/future_impl.dart 571                                      _Future._propagateToListeners
    | dart:async/future_impl.dart 317                                      _Future._complete
    | dart:async/stream_pipe.dart 44                                       _cancelAndValue
    | dart:async/stream.dart 901                                           Stream.first.<fn>
    | dart:async/zone.dart 730                                             _rootRunUnary
    | dart:async/zone.dart 864                                             _RootZone.runUnary
    | dart:async/zone.dart 582                                             _BaseZone.runUnaryGuarded
    | dart:async/stream_impl.dart 333                                      _BufferingStreamSubscription._sendData
    | dart:async/stream_impl.dart 263                                      _BufferingStreamSubscription._add
    | dart:async/stream_controller.dart 569                                _StreamController&&_SyncStreamControllerDispatch._sendData
    | dart:async/stream_controller.dart 449                                _StreamController._add
    | dart:async/stream_controller.dart 406                                add
    | dart:isolate-patch/isolate_patch.dart 124                            _RawReceivePortImpl._handleMessage
FINE: Exception type: CrossIsolateException
ERR : http://127.0.0.1:54296/packages/di/transformer/options.dart 47:11    TransformOptions.TransformOptions
    | http://127.0.0.1:54296/packages/angular/transformer.dart 52:23       _parseSettings
    | http://127.0.0.1:54296/packages/angular/transformer.dart 30:28       AngularTransformerGroup.AngularTransformerGroup.asPlugin
    | dart:mirrors                                                         _LocalClassMirror.newInstance
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 72:37  _initialize.loadFromLibrary.<fn>
    | dart:core                                                            List.addAll
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 54:24  _initialize.loadFromLibrary
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 77:18  _initialize
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 24:25  loadTransformers.<fn>.<fn>
    | http://127.0.0.1:54296/packages/$pub/serialize.dart 92:33            respond.<fn>
    | dart:async                                                           Future.Future.sync
    | http://127.0.0.1:54296/packages/$pub/serialize.dart 92:7             respond
    | http://127.0.0.1:54296/packages/$pub/transformer_isolate.dart 20:12  loadTransformers.<fn>
    | dart:isolate                                                         _RawReceivePortImpl._handleMessage

@taisph
Copy link
Contributor

taisph commented Jul 29, 2014

Could you post the output of pub deps?

@cinan
Copy link
Author

cinan commented Jul 29, 2014

test_app 0.0.1
|-- angular 0.13.0
|   |-- analyzer 0.18.0
|   |   |-- args...
|   |   |-- logging...
|   |   |-- path...
|   |   '-- typed_mock 0.0.4
|   |-- args 0.10.0+2
|   |   '-- collection...
|   |-- barback 0.14.0+3
|   |   |-- collection...
|   |   |-- path...
|   |   |-- source_maps...
|   |   '-- stack_trace...
|   |-- browser...
|   |-- code_transformers 0.1.5
|   |   |-- analyzer...
|   |   |-- barback...
|   |   |-- path...
|   |   '-- source_maps...
|   |-- collection 0.9.4
|   |-- di 2.0.1
|   |   |-- analyzer...
|   |   |-- barback...
|   |   |-- code_transformers...
|   |   '-- path 1.2.2
|   |-- html5lib 0.10.0
|   |   |-- source_maps 0.9.3
|   |   |   '-- path...
|   |   '-- utf 0.9.0+1
|   |-- intl 0.8.10+4
|   |   |-- analyzer...
|   |   |-- meta 0.8.8
|   |   '-- path...
|   |-- perf_api 0.0.8
|   |-- route_hierarchical 0.4.21
|   |   |-- browser...
|   |   '-- logging 0.9.2
|   '-- web_components...
|-- browser 0.10.0+2
|-- crypto 0.9.0
|-- dart_config 0.5.0
|   |-- unittest...
|   '-- yaml 2.0.0
|       |-- collection...
|       |-- path...
|       |-- source_span 1.0.0
|       |   '-- path...
|       '-- string_scanner 0.1.0
|           |-- path...
|           '-- source_span...
|-- js 0.2.2
|   '-- browser...
|-- json_object 1.0.18+2
|-- mock 0.11.0+2
|   '-- matcher 0.11.0
|-- unittest 0.11.0+3
|   |-- matcher...
|   '-- stack_trace 0.9.3+2
|       '-- path...
'-- web_components 0.3.5+1

@taisph
Copy link
Contributor

taisph commented Jul 29, 2014

Thanks. Deps look good too.

Could you pastebin your pubspec.yaml? I'm wondering why the "in" in the "- web/views/in.html" line is bold?

Other than that I'm out of suggestions. I made an empty directory with a web subdir, pasted your pubspec.yaml as above and ran pub upgrade and pub serve web. No errors.

@cinan
Copy link
Author

cinan commented Jul 29, 2014

I looked at transformer.dart source code. So I added to transformers section this line: dart_sdk: /opt/google/dartsdk/ and now it works (as workaround). I'm wondering where is declared dartSdkDirectory variable (used here: https://github.com/angular/angular.dart/blob/master/lib/transformer.dart, line 50).

@taisph
Copy link
Contributor

taisph commented Jul 29, 2014

It is from code_transformers package imported by di which in turn is imported by the file you mentioned.

@rkirov
Copy link
Contributor

rkirov commented Jul 29, 2014

Here is the code_transformers file in question:
https://github.com/dart-lang/bleeding_edge/blob/master/dart/pkg/code_transformers/lib/src/dart_sdk.dart#L22

There are certain assumptions about SdkDirectory with relation to the dart executable accessed through Platform.executable.

You can fix it by adding appropriate symlinks or even better pass dart_sdk argument to the angular transformer as follows:

transformers:
- angular:
    dart_sdk: "/path/to/sdk"

@jonaskello
Copy link

I'm using both Windows and Ubuntu (dart docker image) so it will not work with a siningle hardcoded path in pubspec.yaml and I don't want to maintain two versions of pubspec.yaml.

@rkirov "You can fix it by adding appropriate symlinks"
Exactly what symlinks do I need to setup for this to work?

@zoechi
Copy link
Contributor

zoechi commented Nov 28, 2014

I run this code in the Docker file
RUN sed -i "s{sdkDirectory:.*{sdkDirectory: \"$DART_SDK\"{" pubspec.yaml
which replaces the text after sdkDirectory: with the content of the $DART_SDK variable.

I guess the comment with symlinks means that you can create symlinks so that the Dart SDK can be reached on all systems by the same path.

@jonaskello
Copy link

@zoechi Thanks! Transforming the path in pubspec.yaml during build would work for me too if I didn't have to support development on OSX too (forgot to mention that in the original post). If I put a path in pubspec.yaml then development on both OSX and Windows will not work. But I have it working now. I did not add anything to pubspec.yaml, instead I added this line to the Dockerfile:

RUN ln -s /usr/lib/dart /usr/lib/dart/bin/dart-sdk

@zoechi
Copy link
Contributor

zoechi commented Nov 30, 2014

Nice, thanks for the info!

@adarshaj
Copy link

@jonaskello 👍

@adarshaj
Copy link

adarshaj commented Dec 8, 2014

For future reference, with homebrew on mac with dart 1.8.0, I had to do following:
sudo ln -s /usr/local/Cellar/dart/1.8.0/libexec /usr/local/Cellar/dart/1.8.0/libexec/bin/dart-sdk

#notetoself

@markuswustenberg
Copy link

We've put these lines in our pubspec.yaml:

transformers:
- angular:
    dart_sdk: /opt/google/dartsdk

and then symlinked with ln -s /usr/local/opt/dart/libexec /opt/google/dartsdk (with Dart installed on a Mac with Homebrew). @adarshaj this won't break when Dart is upgraded from v1.8.0.

It would, however, be nice to override the configuration with e.g. an environment variable. Could angular perhaps respect $DART_SDK or similar?

@jonaskello
Copy link

@markuswustenberg I think it is enough to either do the symlink or put the path in pubspec.yaml. You should not have to do both. Also I don't think it is an angular specific issue. If you look up this thread were @rkirov linked the code that probes for the sdk path, it seems to not be a part of angular (it was by reading this code I figured out where to put the symlink). You might want to star these issues which I think are closer to the root cause:

https://code.google.com/p/dart/issues/detail?id=21225
https://code.google.com/p/dart/issues/detail?id=16994
https://code.google.com/p/dart/issues/detail?id=20376

@markuswustenberg
Copy link

@jonaskello Yeah, sorry, I forgot to add that we are running in multiple environments and we've settled for /opt/google/dartsdk for the SDK path. That's the reason for the extra symlink.

I didn't realize it's not an Angular-specific issue, thanks for the pointers.

@zoechi
Copy link
Contributor

zoechi commented Dec 11, 2014

Should be fixed in code_transformers 0.2.3+2 (see http://dartbug.com/21225)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

8 participants