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

error: unexpected character '\n' after patch version number #8

Closed
kevincox opened this issue Aug 1, 2023 · 7 comments · Fixed by #9
Closed

error: unexpected character '\n' after patch version number #8

kevincox opened this issue Aug 1, 2023 · 7 comments · Fixed by #9
Assignees
Labels
bug Something isn't working

Comments

@kevincox
Copy link

kevincox commented Aug 1, 2023

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

# deny.toml
[licenses]
allow-osi-fsf-free = "both"
copyleft = "deny"
allow = [
	"0BSD",
	"BSD-2-Clause",
	"CC0-1.0",
	"ISC",
	"LGPL-2.0",
	"MPL-2.0",
	"OpenSSL",
	"Unicode-DFS-2016",
]
% cargo-deny --log-level debug check
2023-08-01 20:58:50 [INFO] using config from /REDACTED/deny.toml
2023-08-01 20:58:50 [INFO] fetching crates for /REDACTED/Cargo.toml
2023-08-01 20:58:50 [DEBUG] loading license store...
2023-08-01 20:58:50 [INFO] No advisory database configured, falling back to default 'https://github.com/RustSec/advisory-db'
2023-08-01 20:58:50 [DEBUG] Fetching advisory database from 'https://github.com/RustSec/advisory-db'
2023-08-01 20:58:50 [DEBUG] starting new connection: https://github.com/
2023-08-01 20:58:50 [DEBUG] No cached session for DnsName("github.com")
2023-08-01 20:58:50 [DEBUG] Not resuming any session
2023-08-01 20:58:50 [DEBUG] Using ciphersuite TLS13_AES_128_GCM_SHA256
2023-08-01 20:58:50 [DEBUG] Not resuming
2023-08-01 20:58:50 [DEBUG] TLS1.3 encrypted extensions: [ServerNameAck, Protocols([ProtocolName(6832)])]
2023-08-01 20:58:50 [DEBUG] ALPN protocol is Some(b"h2")
2023-08-01 20:58:50 [INFO] fetched crates in 165.549082ms
2023-08-01 20:58:50 [INFO] gathering crates for /REDACTED/Cargo.toml
2023-08-01 20:58:50 [DEBUG] gathering crate metadata
2023-08-01 20:58:50 [DEBUG] loading advisory database from /home/REDACTED/.cargo/advisory-dbs/github.com-a946fc29ac602819
2023-08-01 20:58:50 [DEBUG] finished loading advisory database from /home/REDACTED/.cargo/advisory-dbs/github.com-a946fc29ac602819
2023-08-01 20:58:50 [DEBUG] gathered crate metadata in 207ms
2023-08-01 20:58:50 [ERROR] unexpected character '\n' after patch version number

Expected behavior
The check works.

Screenshots
If applicable, add screenshots to help explain your problem.

Device:

  • OS: Linux, NixOS
@kevincox kevincox added the bug Something isn't working label Aug 1, 2023
@Jake-Shadle Jake-Shadle changed the title Crash: unexpected character '\n' after patch version number error: unexpected character '\n' after patch version number Aug 1, 2023
@Jake-Shadle
Copy link
Member

This comes from semver, but I don't have enough information to repro this, please reopen if you can provide either the output of cargo metadata --format-version=1 or the backtrace for where that error is being produced, as there are dozens of places both in cargo-deny and in its dependencies where this could be coming from.

@kevincox
Copy link
Author

kevincox commented Aug 2, 2023

cargo metadata --format-version=1:

{
  "packages": [
    {
      "name": "deny",
      "version": "0.1.0",
      "id": "deny 0.1.0 (path+file:///home/kevincox/deny)",
      "license": null,
      "license_file": null,
      "description": null,
      "source": null,
      "dependencies": [],
      "targets": [
        {
          "kind": [
            "bin"
          ],
          "crate_types": [
            "bin"
          ],
          "name": "deny",
          "src_path": "/home/kevincox/deny/src/main.rs",
          "edition": "2021",
          "doc": true,
          "doctest": false,
          "test": true
        }
      ],
      "features": {},
      "manifest_path": "/home/kevincox/deny/Cargo.toml",
      "metadata": null,
      "publish": null,
      "authors": [],
      "categories": [],
      "keywords": [],
      "readme": null,
      "repository": null,
      "homepage": null,
      "documentation": null,
      "edition": "2021",
      "links": null,
      "default_run": null,
      "rust_version": null
    }
  ],
  "workspace_members": [
    "deny 0.1.0 (path+file:///home/kevincox/deny)"
  ],
  "resolve": {
    "nodes": [
      {
        "id": "deny 0.1.0 (path+file:///home/kevincox/deny)",
        "dependencies": [],
        "deps": [],
        "features": []
      }
    ],
    "root": "deny 0.1.0 (path+file:///home/kevincox/deny)"
  },
  "target_directory": "/home/kevincox/deny/target",
  "version": 1,
  "workspace_root": "/home/kevincox/deny",
  "metadata": null
}

For me this reproduces with no config on an empty project.

% cargo init deny
     Created binary (application) package
% cd deny 
% cargo-deny check
2023-08-02 12:55:48 [WARN] unable to find a config path, falling back to default config
2023-08-02 12:55:48 [ERROR] unexpected character '\n' after patch version number

@kevincox
Copy link
Author

kevincox commented Aug 2, 2023

% cargo-deny --version
cargo-deny 0.14.0

@Jake-Shadle Jake-Shadle self-assigned this Aug 2, 2023
@Jake-Shadle Jake-Shadle reopened this Aug 2, 2023
@Jake-Shadle
Copy link
Member

What does cargo -V, or $CARGO -V print if you have overriden the cargo path?

@kevincox
Copy link
Author

kevincox commented Aug 2, 2023

% cargo -V
cargo 1.70.0

@Jake-Shadle
Copy link
Member

Ahh ok, I think that's the issue then, I'm guessing you are using a cargo packaged by your distro, the official cargo binary will emit cargo <semver> (<first 7 characters of git SHA-1> <date>) I'll make a fix for that, thanks for the report!

@Jake-Shadle Jake-Shadle transferred this issue from EmbarkStudios/cargo-deny Aug 2, 2023
@kevincox
Copy link
Author

kevincox commented Aug 2, 2023

Ah, great job tracking that down. I am using cargo from NixOS. As a test I pulled the ubuntu:23.10 docker image and it seems to hit the same issue.

It also has the short version string so it seems likely that this is the common factor.

# cargo -V
cargo 1.70.0

The official Rust docker images don't seem to have this problem but they have the expanded version string:

% podman run -it rust:1.70.0-bullseye
root@6263ea194e2d:/# cargo -V
cargo 1.70.0 (ec8a8a0ca 2023-04-25)

Jake-Shadle added a commit that referenced this issue Aug 2, 2023
Non-official cargo builds may have differing output for `cargo -V` that
the previous code wasn't accounting for, the output is now properly
trimmed to remove excess whitespace before attempting to parse it into a
semver.

Resolves: #8
Jake-Shadle added a commit to EmbarkStudios/cargo-deny that referenced this issue Aug 2, 2023
Updates dependencies, notably bringing in tame-index 0.2.5 which brings
in the fix for EmbarkStudios/tame-index#8
which was originally reported to this repo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants