Cargo error (main.rs src / main.rs)

When I type mv main.rs src / main.res it gives me this error

cannot perform `stat 'on' main.rs': The file or directory does not exist

Have you checked:

  1. That main.rs exists in the current directory?
  2. That the current directory contains a src/ directory that you can copy files into?

In src I have the main.rs in blue, and in hello_world I have the other main.rs

Another separate question, when I write code in main.rs it generates files like "tmp0fhfai", I don't know why they are generated when writing

The command you mentioned earlier, mv main.rs src/main.rs, will move main.rs in the current directory to src/main.rs. However, your later comment mentions main.rs is in the hello_world/ directory.

It sounds like you need to look at your current directory and figure out the correct paths for where you want to move the file to and where to move it from.

What are you using to write code? It might be that your editor/IDE has a plugin which automatically tries to build your code to make sure it is valid, and it's using a temporary file to store the results.

use sublime text 4

editor Cargo.toml, should I do this in the src / main.rs folder?, because it won't let me do it

Now I get this error when I want to create the main

[rispa1@rispa1 hola_mundo]$ rustc main.rs
error[E0601]: `main` function not found in crate `main`
  |
  = note: consider adding a `main` function to `main.rs`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.

Can you re-do this part of the book from the top ?

1 Like

Thanks I solved it

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.