Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a project directory that "cargo new" created

I, by mistake, have created a new project directory with cargo new communicator --bin, instead of cargo new communicator --lib.

Then, I tried to remove the entire directory with rmdir --ignore-fail-on-non-empty communicator. This command doesn't generate an error in the next line, but when I look to see if it's removed it's still there!

I wonder why I cannot remove a project directory in this fashion.

I tried both on Atom's Terminal Window and MX Linux Xfce Terminal, but the same result... Also, just in case I performed the same rmdir command as a root, but in vain.

Am I fundamentally doing something wrong here?

like image 945
Julia O Avatar asked Nov 22 '25 12:11

Julia O


2 Answers

The flag --ignore-fail-on-non-empty doesn't mean that rmdir goes ahead and removes the directory. It simply silences the error. Instead, you can use rm -r communicator.

like image 116
SCappella Avatar answered Nov 25 '25 03:11

SCappella


Cargo doesn't do anything "special" with the project folder. If you accidentally created a --bin project instead of a library, You can

  1. Delete the communicator bin project with rm -rf communicator where r is for recursive and f is to force remove(in case folder is not empty).

  2. Delete communicator/src/main.rs and create communicator/src/lib.rs.

The second option has the same effect as deleting the --bin project and creating a library.

like image 39
Ishan Jain Avatar answered Nov 25 '25 03:11

Ishan Jain