clap-cargo icon indicating copy to clipboard operation
clap-cargo copied to clipboard

Fallback to workspace if workspace_default_members is unavailable

Open foresterre opened this issue 10 months ago • 0 comments
trafficstars

NB: Draft because it requires a new release of https://github.com/oli-obk/cargo_metadata (which will include the new API's which can be used to check the presence of the the workspace_default_members field https://github.com/oli-obk/cargo_metadata/pull/282)

When cargo_metadata is invoked with a Cargo version < 1.71, which doesn't support workspace default members, the workspace_default_members field in cargo_metadata will be empty. Dereferencing this field will then cause a panic. To prevent partition_packages to panic when used with older Cargo versions, we check the presence of the field, and if it is missing, we default to the workspace instead.

Do you agree that selecting the workspace, if workspace_default_members is unavailable, would be the right behaviour?

fixes #62

See also: issue https://github.com/oli-obk/cargo_metadata/issues/254 "Don't panic from WorkspaceDefaultMembers?"

foresterre avatar Jan 03 '25 04:01 foresterre