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

cargo vendor suggests vendor source config in inline form instead of separate tables #10345

Closed
weihanglo opened this issue Jan 31, 2022 · 1 comment · Fixed by #10348
Closed
Labels
C-bug Category: bug

Comments

@weihanglo
Copy link
Member

weihanglo commented Jan 31, 2022

Problem

This is not actually a bug but the original form is more readable IMO.

With 1.60.0-nightly:

To use vendored sources, add this to your .cargo/config.toml for this project:

source = { crates-io = { replace-with = "vendored-sources" }, vendored-sources = { directory = "vendor" } }

With 1.58.1 stable:

To use vendored sources, add this to your .cargo/config.toml for this project:

[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"

Steps

  1. cargo +nightly vendor in any crate with dependencies.
  2. Will see suggested vendor config in inline form.

Possible Solution(s)

I guess it is due to the switch to toml_edit from toml. It should output in the same form as before, though I am afraid the fix might not be too easy.

cc @epage since you're an expert of toml_edit 😆

Notes

There might be other places got this kind of bug but I haven't had a time to scan all of them.

Version

cargo 1.60.0-nightly (1c034752d 2022-01-25)
release: 1.60.0-nightly
commit-hash: 1c034752de0df744fcd7788fcbca158830b8bf85
commit-date: 2022-01-25
host: x86_64-apple-darwin
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.77.0 (sys:0.4.51+curl-7.80.0 system ssl:(SecureTransport) LibreSSL/2.8.3)
os: Mac OS 12.2.0 [64-bit]
@weihanglo weihanglo added the C-bug Category: bug label Jan 31, 2022
@epage
Copy link
Contributor

epage commented Jan 31, 2022

This is one of the differences between toml-rs and toml_edit. toml-rs preferred creating tables while toml_edit always keep things as values unless formatted otherwise.

An easy way to fix this is to use to_string_pretty which does favor tables.

I'll get a PR together for this.

epage added a commit to epage/cargo that referenced this issue Jan 31, 2022
Inspired by rust-lang#10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`.  The crates v1 file was
the only case I found.

As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests.  This was the behavior before `toml_edit`,
so not much of a loss.
bors added a commit that referenced this issue Jan 31, 2022
fix(vendor): Use tables for sample config

Fixes #10345
@bors bors closed this as completed in fb9d11b Jan 31, 2022
bors added a commit that referenced this issue Feb 1, 2022
fix(install): Keep v1 file formatting the same

Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`.  The crates v1 file was
the only case I found.

As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests.  This was the behavior before `toml_edit`,
so not much of a loss.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants