Skip to content

Cargo emits confusing errors when trying to use example crates #10173

@mejrs

Description

@mejrs

Problem

Cargo emits confusing errors when trying to use example crates

Steps

When you have an example crate, and define it in the main crate's cargo.toml with

[[example]]
name = "example1"
path = "examples/example1"

commands like cargo check --examples gives useless errors like:

  • error: couldn't read examples/example1: Access is denied. (os error 5) on Windows,
  • error: couldn't read examples/example1: Is a directory (os error 21) on Ubuntu/MacOS

Possible Solution(s)

It would be nice if this would Just Work. But otherwise it would be friendlier to nudge users to something like

[[example]]
name = "example1"
path = "examples/example1/src/main.rs"

rather than emitting useless error messages

Notes

No response

Version

cargo 1.57.0 (b2e52d7ca 2021-10-21)
release: 1.57.0
commit-hash: b2e52d7cab0a286ee9fcc0c17510b1e72fcb53eb
commit-date: 2021-10-21
host: x86_64-pc-windows-msvc
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.79.1-DEV (sys:0.4.49+curl-7.79.1 vendored ssl:Schannel)
os: Windows 10.0.19043 (Windows 10 Home) [64-bit]

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions