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

document that repository_ctx.template requires text files #11857

Closed
guibou opened this issue Jul 28, 2020 · 3 comments
Closed

document that repository_ctx.template requires text files #11857

guibou opened this issue Jul 28, 2020 · 3 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@guibou
Copy link
Contributor

guibou commented Jul 28, 2020

Description of the problem / feature request:

repository_ctx.template seems to corrupt binaries files. For example:

repository_ctx.template(outPath, binaryFilePath)

Will results in a corrupted file in outPath. Tested with sha256sum.

Feature requests: what underlying problem are you trying to solve with this feature?

Using repository_ctx.template as a way to copy file. I do realize that it is an abuse of the API, but there is no repository_ctx.copy.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Replace this line with your answer.

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

release 3.2.0- (@non-git)

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

nixpkgs

Have you found anything relevant by searching the web?

no.

@oquenchil oquenchil added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug untriaged labels Jul 28, 2020
@alandonovan
Copy link
Contributor

alandonovan commented Sep 3, 2020

As I commented at #11858 (comment), yes, template will indeed not work for binary files. Strings, in the Java implementation of Starlark used by Bazel, are intended to be strings of UTF-16 codes (chars), like strings in Java, and are thus incapable of representing binary files. A copy function seems like a better approach.

So the code is working as in intended, but the documentation is not.

@alandonovan alandonovan changed the title repository_ctx.template corrupts binary files document that repository_ctx.template requires text files Sep 3, 2020
@philwo philwo added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Nov 25, 2020
guibou added a commit to tweag/rules_nixpkgs that referenced this issue Mar 21, 2021
This closes #136

`repository_ctx` is meant to work on "text" files and does text encoding
and decoding, which breaks in the context of a binary file.

There is no `cp` API in repository_ctx, as suggested in
bazelbuild/bazel#11858, but
bazelbuild/bazel#11857 suggested to use this
approach with `repository_ctx.file`.
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label May 24, 2023
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

4 participants