Skip to content

cargo doc works but cargo publish fails due to include_str! in lib.rs with relative path  #13309

@softstream-link

Description

@softstream-link

Problem

I have multi module project with following members
Cargo.toml

[workspace]
members = ["core", "nonblocking", "blocking", "bindings/python"]
....

Which includes readme's in the rust doc like so
nonblocking/src/lib.rs

#![doc = include_str!("./../../readme.md")]
....

I am able to run cargo doc --open which creates the website and opens the documentation correctly, however then trying to publish the nonblocking crate it fails saying.
Error from `cargo publish -p links_nonblocking --dry-run

error: couldn't read src/./../../readme.md: No such file or directory (os error 2)
 --> src/lib.rs:1:10
  |
1 | #![doc = include_str!("./../../readme.md")]

Steps

  1. git clone from this branch - https://github.com/softstream-link/links/tree/v2
  2. try
  • PASSES : cargo doc ; # will have the readme.md successfully included
  • FAILS : cargo publish -p links_nonblocking --dry-run ; # will fails saying it can't find the include_str path.

Possible Solution(s)

Do these two commands use two different cwd when running for each modules? if so what is the workaround this?

Notes

na

Version

cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 7.87.0 (sys:0.4.68+curl-8.4.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 13.3.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions