dart-archive / rpc

RPC package for building server-side RESTful Dart APIs.
https://pub.dartlang.org/packages/rpc
BSD 3-Clause "New" or "Revised" License
117 stars 49 forks source link

Support --no-packages-dir #101

Closed xvrh closed 6 years ago

xvrh commented 8 years ago

When I run pub get --no-packages-dir and then pub run rpc:generate discovery -i lib/server.dart. I get this error: Please run 'pub get' in your API package before running the generator.

It seems there is a check for the packages/ subfolders in the class ClientApiGenerator. If I manually remove the check in the code everything seems fine.

alextekartik commented 7 years ago

This is definitely now a big issue, now than dart 1.20 is out with no symlink by default. The workaround for now is to do pub get --packages-dir first in the server project

enyo commented 7 years ago

Also having this problem. Any workarounds yet (apart from --packages-dir)? Now that 1.20.1 is out, the default is to exclude the packages dir.

enyo commented 7 years ago

We're now at dart version 1.24.x and I'm afraid that the --packages-dir will be removed soon and we won't be able to upgrade because of this dependency. Is there any news regarding this issue or plans on how to fix it?

enyo commented 7 years ago

@mkustermann I guess that you would know?

sanmadjack commented 7 years ago

I've got a workaround, if you enable the discovery document generation on your RPC server you can just download the JSON from your server. This doesn't lend well to continuous integration, but it gets the job done until they've got this worked out. Check the readme file, search for "ApiServer.enableDiscoveryApi()".

enyo commented 7 years ago

Thanks @sanmadjack. Unfortunately we really need it in our CI, so we can't go this route.

sanmadjack commented 7 years ago

You can, just in your CI environment start the server (or start a subset of the server with the generator enabled), and then use curl (or platform equivalent) to fetch the json file, then continue processing as normal.

xvrh commented 7 years ago

For info, I worked around this bug simply by forking the repo and remove the pub check:

https://github.com/xavierhainaux/rpc/commit/bcd774caa31cf6d91a6f2a54243d86a971935ca4

sanmadjack commented 7 years ago

@xavierhainaux Is it a good enough change for a pull request?

xvrh commented 7 years ago

@sanmadjack I don't know, it works for my usage. I guess there is some limitation or the check would not have been there.

jakobr-google commented 7 years ago

It looks like this was already fixed, in https://github.com/dart-lang/rpc/commit/c658881841fe311ebb0629276cdec53b91a8c847.

I think we just need to push a new release. In the meantime, you should be able to add a dependency override to get the latest code from github (https://www.dartlang.org/tools/pub/dependencies#git-packages):

dependency_overrides:
  rpc:
    git: git://github.com/dart-lang/rpc.git
jakobr-google commented 6 years ago

@mkustermann could you publish a new release, please?

mkustermann commented 6 years ago

Sorry for the delay, I've published a new version in 15cd18042804a014fdcbad5456c31038db9ca431. Does this fix the issues you're seeing?