Skip to content

GenerateCopyright attempts to vendor sources during installation #136955

Closed

Description

@Kangie

Gentoo Linux builds are primarily performed in a sandbox that prevents network activity after sources are fetched.

Unfortunately this leaves us unable to package nightly as GenerateCopyright is invoked by x.py install, which attempts to vendor crates into the build directory.

  1. GenerateCopyright should only be run when generating the source tarball, or should at the very least at least be a separate step from Rustc
  2. src/tools/generate-copyright should respect config.vendor

I tried this:

`x.py install ...

I expected to see this happen:

A successful installation into DESTDIR

Instead, this happened:

running: cd "/var/tmp/portage/dev-lang/rust-9999/work/rust-9999" && CARGO="/opt/rust-bin-9999/bin/cargo" DEST="/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/build/COPYRIGHT.html" DEST_LIBSTD="/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/build/COPYRIGHT-library.html" LD_LIBRARY_PATH="/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/opt/rust-bin-9999/lib" LICENSE_METADATA="/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/license-metadata.json" OUT_DIR="/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/build" RUSTC="/opt/rust-bin-9999/bin/rustc" "/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/build/x86_64-unknown-linux-gnu/stage0-tools-bin/generate-copyright" (failure_mode=Exit) (created at src/bootstrap/src/core/build_steps/tool.rs:1211:23, executed at src/bootstrap/src/core/build_steps/run.rs:224:13)
Vendoring deps into /var/tmp/portage/dev-lang/rust-9999/work/rust-9999/build/vendor...
error: failed to sync

Caused by:
  failed to load pkg lockfile

Caused by:
  failed to get `tikv-jemalloc-sys` as a dependency of package `rustc-main v0.0.0 (/var/tmp/portage/dev-lang/rust-9999/work/rust-9999/compiler/rustc)`

Caused by:
  download of config.json failed

Caused by:
  failed to download from `https://index.crates.io/config.json`

Caused by:
  [6] Could not resolve hostname (Could not resolve host: index.crates.io)
Error: Failed to complete cargo vendor

rust-9999:20250213-003653.log.xz.txt

rustc --version --verbose:

rustc 1.86.0-nightly (92bedea1c 2025-02-11)
binary: rustc
commit-hash: 92bedea1c51e3a969d60972be854506ffd8c5cb6
commit-date: 2025-02-11
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 13, 2025
  2. jyn514 commented on Feb 13, 2025

    @jyn514
    Member

    This happens because x install internally invokes x dist, which includes x dist rustc. dist::Rustc unconditionally calls builder.ensure(GenerateCopyright). I don't think those two components should be coupled together like that, GenerateCopyright should only be run when generating PlainSourceTarball.

    @rustbot label T-bootstrap A-licensing

  3. jyn514 commented on Feb 13, 2025

    @jyn514
    Member

    I think running cargo vendor with the same vendor/ directory as the root actually overwrites any existing vendor sources. so, that's another bug here. all the vendoring needs to be done in a single invocation managed by bootstrap, not piecemeal.

  4. jyn514 commented on Feb 13, 2025

    @jyn514
    Member
  5. added
    A-licensingArea: Compiler licensing
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    on Feb 13, 2025
  6. jonathanpallant commented on Feb 13, 2025

    @jonathanpallant
    Contributor

    The generated HTML needs to be shipped with the binary dist of rustc, not the source tarball, because it contains all things that must be supplied alongside any 'redistribution' of 'the software'.

    cc @pietroalbini

  7. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 13, 2025
  8. jonathanpallant commented on Feb 13, 2025

    @jonathanpallant
    Contributor

    Probably shouldn't be vendoring twice though - I can look at using the existing vendor folder if one has already been fetched.

  9. jyn514 commented on Feb 13, 2025

    @jyn514
    Member

    please do not try to replicate the vendoring logic in a separate tool. instead, do the vendoring all in one place in bootstrap.

    i understand that this may run even when config.vendor is disabled, so you could switch on that in bootstrap (ideally it would put sources used only for parsing copyright in a different directory on disk). but it should not live in a separate tool.

  10. Kangie commented on Feb 13, 2025

    @Kangie
    Author

    The generated HTML needs to be shipped with the binary dist of rustc, not the source tarball, because it contains all things that must be supplied alongside any 'redistribution' of 'the software'.

    I can't see any reason that shipping it in a tarball doesn't meet those requirements. We don't even use html files in Gentoo anyway; we have our own mechanism for identifying and managing licensing (and most [all?] distros do the same thing).

    If I needed to refer to them I would:

    1. Grab a copy from an appropriate tarball
    2. Build a copy myself from an appropriate git tag

    It seems superfluous to run that implicitly as part of the bootstrap x.py install component.

  11. emilyalbini commented on Feb 14, 2025

    @emilyalbini
    Member

    please do not try to replicate the vendoring logic in a separate tool. instead, do the vendoring all in one place in bootstrap.

    Yeah, I'll open a PR soon to have bootstrap retrieve the vendored sources (from config.vendor or from the network if needed) and pass them to generate-copyright.

    I can't see any reason that shipping it in a tarball doesn't meet those requirements. We don't even use html files in Gentoo anyway; we have our own mechanism for identifying and managing licensing (and most [all?] distros do the same thing).

    [...]

    It seems superfluous to run that implicitly as part of the bootstrap x.py install component.

    When the Rust project distributes pre-built binaries, we cannot distribute the license file just in the source tarball: if an user just downloads rustc-1.84.0-$target.tar.xz they need to receive the licenses. Those tarballs are produced by x.py dist.

    To reduce duplication, x.py install executes x.py dist behind the scenes (with a few variations), so it inherits all of the behavior of x.py dist, including generating the license files. Requiring network access when using vendored sources is a bug that will be fixed, but if you want to disable generating the licensing information altogether that'd be a separate issue.

  12. emilyalbini commented on Feb 14, 2025

    @emilyalbini
    Member

    Opened #137020 with the fix.

  13. added a commit that references this issue on Feb 17, 2025
  14. added a commit that references this issue on Feb 18, 2025
  15. jieyouxu commented on Feb 23, 2025

    @jieyouxu
    Member

    Reopening to track beta-backport of #137020.

  16. kulp commented on May 3, 2025

    @kulp
    Member

    I might be running into this problem. @jieyouxu was the closure of this item via flodiebold/rust-analyzer@a6b4f34 actually correct? I am unfamiliar with the beta-backport process, but I do not see how a fork of rust-analyzer would close this.

  17. jieyouxu commented on May 3, 2025

    @jieyouxu
    Member

    No, the cross-repo closure is not expected.

  18. jieyouxu commented on May 3, 2025

    @jieyouxu
    Member

    However, the beta backport of #137020 was included in #137747.

  19. jieyouxu commented on May 3, 2025

    @jieyouxu
    Member

    That being said, please open a new issue for ur problem, I think this issue is actually fixed.

    e.g. follow-ups like #137272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-licensingArea: Compiler licensingC-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions