Azure / Azure/azure-rest-api-specs

SDK Validation: Rust `cargo fmt` step fails on sample typespec project

Open
#43,099 21 comments 0 reactions 1 assignee Claimed by @jhendrixMSFT View on GitHub
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

## Rust check failed in `cargo fmt` step for sample typespec project

The 'tsp-client' command returns an error at the cargo fmt step for a sample typespec-based Rust project.
[Pipeline Run](https://dev.azure.com/azure-sdk/public/_build/results?buildId=6281764&view=logs&j=83516c17-6666-5250-abde-63983ce72a49&t=00be4b52-4a63-5865-8e02-c61723ad0692)

### Error output
```
Running command [/mnt/vss/_work/1/s/azure-sdk-for-rust/eng/common/tsp-client/node_modules/.bin/tsp-client init --update-if-exists --tsp-config /mnt/vss/_work/1/s/azure-rest-api-specs/specification/widget/data-plane/WidgetAnalytics/tspconfig.yaml --repo Azure/azure-rest-api-specs] with timeout 30 minutes in /mnt/vss/_work/1/s/azure-sdk-for-rust

[npm-tsp-client] error CargoFmt: Command failed: cargo fmt -- --emit files
[npm-tsp-client] `cargo metadata` exited with an error: error: current package believes it's in a workspace when it's not:
[npm-tsp-client] current: /mnt/vss/_work/1/s/azure-sdk-for-rust/sdk/widgetanalytics/azure_widget_analytics/Cargo.toml
[npm-tsp-client] workspace: /mnt/vss/_work/1/s/azure-sdk-for-rust/Cargo.toml
[npm-tsp-client]
[npm-tsp-client] this may be fixable by adding `sdk/widgetanalytics/azure_widget_analytics` to the `workspace.members` array of the manifest located at: /mnt/vss/_work/1/s/azure-sdk-for-rust/Cargo.toml
[npm-tsp-client] Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
```

### Steps to Reproduce
1. Run the 'tsp-client' command on a sample typespec-based Rust project that uses the default workspace settings.
2. Observe the failure during the `cargo fmt` step if the module is not listed as a workspace member or excluded properly in the root Cargo.toml.
3. Check the error logs for workspace configuration errors in the formatting job.

### Expected Behavior
The `cargo fmt` step should succeed without workspace-related errors.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.