Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building project results in dart packages not being in appropriate location #21127

Closed
DartBot opened this issue Sep 28, 2014 · 11 comments
Closed
Labels
closed-as-intended Closed as the reported issue is expected behavior

Comments

@DartBot
Copy link

DartBot commented Sep 28, 2014

This issue was originally filed by daniel.robinson.open...@gmail.com


  1. Get latest from https://github.com/0xor1/purity_oauth2/tree/integration-test
  2. run pub build
  3. run build/test/integration/bin/host.dart

Expect the program to start running, but it fails as it cannot find the packages directory, if I manually copy the packages folder from build/test to build/test/integration/bin then it does work:
Unhandled exception:
Uncaught Error: FileSystemException: Cannot open file, path = 'D:\Projects\purity_oauth2\build\test\integration\bin\packages\purity\host.dart' (OS Error: The system cannot find the path specified.

Dart Editor version 1.6.0.release (STABLE)
Dart SDK version 1.6.0
Windows 8.1 x64

@sgjesse
Copy link
Contributor

sgjesse commented Sep 29, 2014

Added Area-Pub, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Sep 29, 2014

This comment was originally written by daniel.robinson...@gmail.com


The link to the github repo has changed, you can now use eith master or dev branches to achieve the exact same result, the integration-test branch has been merged down to both

@nex3
Copy link
Member

nex3 commented Sep 29, 2014

Part of the point of "pub build" is that it doesn't produce any symlinks, since they're not portable. At the same time, we don't want it to copy the packages directory into every place that it could possibly be used.

For now, the best solution is to use absolute URLs to refer to the packages directory in the root of your application. Issue #15808 is tracking the addition of a transformer to fix up URLs automatically.


Added AsDesigned label.

@DartBot
Copy link
Author

DartBot commented Sep 29, 2014

This comment was originally written by daniel.robinson...@gmail.com


so its preferable to use:

import '../../../packages/package/name/lib.dart'

rather than:

import 'package:package/name/lib.dart';

I would have assumed that the latter should always "just work"

@DartBot
Copy link
Author

DartBot commented Sep 29, 2014

This comment was originally written by daniel.robinson...@gmail.com


also ../../../packages is to get from the source file location in the project to the packages directory in the project root, but that doesn't match with in my particular case which would require the build file editing to ../../packages since the built packages directory is inside build/test not the root build folder.

@nex3
Copy link
Member

nex3 commented Sep 29, 2014

Currently "pub build" isn't really designed to deploy Dart entrypoints that aren't compiled to Javascript, since there aren't browser that support that in the wild. Once there are, the suggested means of deployment will be using dart2dart to compile them to a single file.

@DartBot
Copy link
Author

DartBot commented Sep 29, 2014

This comment was originally written by daniel.robinson.open...@gmail.com


there isn't support in the wild? one of my dart entry points is for a stand alone console app that is just run directly in the dartVM so doesnt have the lack of native browser support issue, also the other 2 entry points in my app are browser side entry points which are compiled to javascript, but the index files fail to start because it can't find the dart.js file required to boot the application on page load.

@nex3
Copy link
Member

nex3 commented Sep 29, 2014

"pub build" doesn't really support deploying code to the VM yet (issue #20248). As for browser entrypoints, the .dart.js files should end up in the same location that the Dart source files were originally.

@DartBot
Copy link
Author

DartBot commented Sep 30, 2014

This comment was originally written by daniel.robinson.o...@gmail.com


yest the .dart.js files do end up where they originally where but when the .html file references <script src="packages/browser/dart.js"></script> it fails to find the actual "dart.js" file because it can't find the packages directory, and as I said in my previous comment making the path relative to "../../../packages/browser/dart.js" isn't particularly nice because when you build the project you then need to manually change that relative path to have one less ../ in it as the packages directory in the build folders is in a different relative location. At the end of the day it just isn't very nice and doesn't work, which is odd because I've had similar projects in the past which did work.

I remember certain builds that had multiple package directories throughout them and those package directories only contained the packages that were required in that location, so typically just browser with interop.js and dart.js in it, and everything just worked, now it doesn't sadly.

@nex3
Copy link
Member

nex3 commented Oct 13, 2014

Why not just use the root-relative URL "/packages/browser/dart.js"?

Way back when we first introduced "pub build", it had specific special-case handling for the browser package that put its JS files in packages directories throughout the output. We decided that wasn't something we wanted to do for all packages, though, so we discontinued that behavior.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/pub#1151.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-as-intended Closed as the reported issue is expected behavior
Projects
None yet
Development

No branches or pull requests

4 participants