Git Product home page Git Product logo

Comments (8)

vzsg avatar vzsg commented on June 29, 2024

Hi. Thanks for opening the issue, and sorry for the delayed response.
Unfortunately I have no idea how resources work on Linux, but I'll ask around.

By the way, can you share some code? Particularly how you're trying to access that folder?

from heroku-buildpack.

vzsg avatar vzsg commented on June 29, 2024

Also, do you have that "SpotifyWebAPI.doccarchive" folder committed to source control? The buildpack, especially on Swift 5.4 and before, will not compile DocC by itself.

from heroku-buildpack.

vzsg avatar vzsg commented on June 29, 2024

Do I assume correctly that you are trying to deploy this project? https://github.com/Peter-Schorn/SpotifyAPIDocs

from heroku-buildpack.

vzsg avatar vzsg commented on June 29, 2024

Doubling down on that "help-wanted" label, I deployed your repository to Heroku and found this in the logs.
(Sidenote: it would've been useful to have this in the original issue.)

2021-06-29T18:30:48.624997+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 4728`
2021-06-29T18:30:52.295359+00:00 app[web.1]: VaporDocC/resource_bundle_accessor.swift:11: Fatal error: could not load resource bundle: from /tmp/codon/tmp/cache/heroku-20/swiftenv/versions/5.4.2/usr/bin/SpotifyAPIDocs_VaporDocC.resources or /tmp/build_a14d8f44/.build/x86_64-unknown-linux-gnu/release/SpotifyAPIDocs_VaporDocC.resources
2021-06-29T18:30:52.791165+00:00 app[web.1]: 0x7f3bbe6c03bf
2021-06-29T18:30:52.791183+00:00 app[web.1]: 0x7f3bbe843307
2021-06-29T18:30:52.791184+00:00 app[web.1]: 0x55dc9ded7ad7, closure #1 () -> Foundation.Bundle in variable initialization expression of static (extension in VaporDocC):Foundation.Bundle.module : Foundation.Bundle at /tmp/build_a14d8f44/.build/x86_64-unknown-linux-gnu/release/VaporDocC.build/DerivedSources/resource_bundle_accessor.swift:11

Unfortunately, this suggests that Swift hardcodes the build path to the binary, so even though the resources folder is copied right next to the binary (which is done by the buidpack), the app will not see them.

from heroku-buildpack.

Peter-Schorn avatar Peter-Schorn commented on June 29, 2024

Do I assume correctly that you are trying to deploy this project? https://github.com/Peter-Schorn/SpotifyAPIDocs

Yes, I want to deploy this project.

Unfortunately, this suggests that Swift hardcodes the build path to the binary, so even though the resources folder is copied right next to the binary (which is done by the buidpack), the app will not see them.

I assumed that the resources folder was not copied at all. Is there any way I can reliably retrieve the correct path to the resources folder? Perhaps I should create a docker image instead and deploy that. However, I'm not sure how to correctly set up that either.

It doesn't matter to me how resource access is implemented; I just need a reliable solution.

from heroku-buildpack.

vzsg avatar vzsg commented on June 29, 2024

If you want a reliable solution, don't use Bundle.module until we can figure something out.

I have two workaround ideas in the meantime:

  • Stick to serving files directly from the project folder (like FileMiddleware).
  • Use Bundle(path: "/app/.swift-bin/SpotifyAPIDocs_VaporDocC.resources") before Bundle.module – that's the path where the resources are copied by the buildpack.

from heroku-buildpack.

vzsg avatar vzsg commented on June 29, 2024

For the record, I found where the hardcoded temporary paths are coming from in SPM's sources.

I have absolutely no idea why it's implemented like that, and why the toolchain's bin folder end up being used as the main bundle path. Or how Swift apps with resources are supposed to be portable between systems...

from heroku-buildpack.

vzsg avatar vzsg commented on June 29, 2024

I've found a bug report about this exact issue, and it will be fixed in Swift 5.5. The fix is already part of the 5.5-DEVELOPMENT-SNAPSHOT-2021-06-26-a version, which is supported by the buildpack, I've just finished testing it.

So, for the third workaround, you can set the Swift version used to 5.5-DEVELOPMENT-SNAPSHOT-2021-06-26-a with either a .swift-version file or with the SWIFT_VERSION config variable and build again.

Until 5.5 is released, unfortunately there is nothing I can do to fix Bundle.module.

from heroku-buildpack.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.