First of all: I'm really new to Rust, Therefore I ask for help for a fool.
My System: Win10 + current version of Rust and VSCode
I have created a workspace in Rust in which various crates are created under the "korpus" folder and everything works quite well.
Now I have created the bench-folder on a higher folder level under the folder coderevision and there again my file neuronen_benchmark.rs to run the benchmark.
I know that this configuration is unusual, but this is my choice.
Now when I run the command: cargo bench I am asked to do this: "Please specify bench.path if you want to use a non-default path."
I've tried a lot, but can't find a solution. I did a google search for the term but could not find it
What do I have to do specifically (please provide detailed instructions) so that cargo bench automatically knows where my bench folder is located?
I am very grateful for any help, as I am simply stuck here
Thanks for the little hint.
Nevertheless, this does not change the fundamental problem
I have corrected the name of the folder and logically I still get the same error message
If your configuration is unusual, you have to put in a little more effort to tell Cargo where to find your benchmarks, by explicitly defining them in your Cargo.toml. Please try and add this to the Cargo.toml file of your workspace and see if it solves your problem:
[[bench]]
name = "neuronen_benchmark"
path = "coderevision/benches/neuronen_benchmark.rs"
As a side node, it would be better and more accessible to people that rely on screen readers if you could share your code not via screenshots, but copied and wrapped in a code block like this:
```
your code
```
You can share your directory structure by running tree . in your console with your workspace directory as the working directory (on Linux, but I think on Windows as well).
First of all, thank you very much for your helpful tips. I still have a lot to learn.
Although your suggestion with: path = "coderevision/benches/neuronen_benchmark.rs"
only produced a different error message: error: couldn't read corpus\neurons\coderevision/benches/neurons_benchmark.rs:
this gave me the idea of using an absolute path and it worked immediately. path = "/40-Rust/Projekte/inkubator/coderevision/benches/neuronen_benchmark.rs"
Maybe you just have to modify your suggested path to make it work?
I have already tried a few variants but unfortunately without success. Do you have any other ideas?
What I found striking about the error message is that there are backslashes at the beginning and slashes at the end, which I perceive as inconsistent
Ah yes. I thought you were adding the path to the workspace's Cargo.toml, not the korpus/neuronen/Cargo.toml file. In that case your path must be ../../coderevision/benches/neuronen_benchmark_rs, as Cargo interprets relative paths as being relative to the package's root directory (korpus/neuronen in your case).
Yes, it makes sense that you can't define targets in a virtual workspace, my bad for suggesting it.
As to your problem with the path, I have no idea why it doesn't work with a relative path. I've recreated your project structure and added
[[bench]]
name = "neuronen_benchmark"
path = "../../coderevision/benches/neuronen_benchmark.rs"
to my korpus/neuronen/Cargo.toml and it executes the benchmarks from that file. I'm running on Linux though, I don't know if there's something one has to do differently on Windows.
cc @weihanglo (hope it is alright to tag you here. I thought it'd be easier than opening a new issue as I believe there must be some other explanation than a bug to why a relative path doesn't work but an absolute path does—it's probably just me missing something)
Hmm… I am not sure how it didn't work out. Almost all Windows APIs support forward and backward slashes. Unfortunately I have no spare Windows machine at hands .
I would suggest not using relative paths outside the package root directory. It might cause problems when sharing the package, and when running cargo package it would be an error if I remember correctly. I would recommend symlinks.