Could not find `Cargo.toml`

The screenshot shows that cargo.toml is there, but there is an error when starting

:sob:

It looks like you placed it under target/

3 Likes

Cargo.toml is under the guessing_game directory. In your terminal, do cd guessing_game and then run cargo run

1 Like

изображение

It should be in the root directory. In guessing_game.

3 Likes

thanks, but it didn't work

And you also need to be in the guessing_game directory when you run it. Currently, it looks like you are in the parent directory of guessing_game.

2 Likes

i in directory guessing_game

Whenever you say something didn't work, be sure to post the full error message from running cargo build or cargo check from the terminal (not from the IDE).

1 Like

error: could not find Cargo.toml in C:\Users\nt\rust01 or any parent directory
PS C:\Users\nt\rust01>

изображение

That means you're running it from rust01, you should be in guessing_game. It may help to do a pwd and find . also to show us where you are and the contents of the directory.

2 Likes

You want

rust01/
    guessing_game/
        src/
            main.rs
        target/
        Cargo.toml

Or for clarity, I'll list Cargo.toml first inside the guessing_game folder:

rust01/
    guessing_game/
        Cargo.toml
        src/
            main.rs
        target/

If it helps, it should be next to Cargo.lock and .gitignore

2 Likes

how do I get into directory guessing_game?

I don't understand what I need to do((((

You're so close :slight_smile:

Are you able to open a new terminal in your ide and run the command:

ls

I expect you'll see

guessing_game

If so, you'll then be able to change directory, in the terminal, by running another command:

cd guessing_game
4 Likes

Thank you very much, this helped me

1 Like

Run ls again, to list the files and folders.

You'll notice that you have not got a Cargo.toml in that directory.

That's OK, it's inside src/ and we want to move it up out of that folder and into guessing_game folder:

mv src/Cargo.toml ./

Ought to do just that. (Though I forget exactly which Linux style commands powershell understands)

If that does fail, you ought to be able to drag and drop the file using the IDE, double check it is there afterwards.

Finally, while you're inside guessing_game/ run:

cargo build

Best bet is to close this project down and open guessing_game as a project instead, that way you'll always start in guessing_game/ and things ought to work a bit better for it :slight_smile:

2 Likes

:pray:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.