./main
zsh: no such file or directory: ./main
If you are trying to run a Rust Language program on your Terminal and you get "no such file or directory", well there could be two reasons for this error,
- You have not compiled your program yet, hence the complied file is not yet created. You can compile your Rust Program file as follows,
rustc <file-name.rs>
- If you think you have completed your file, then make sure that file exists at the location you are running it. Do a dir or ls command in the Terminal/Command Prompt to check based on your Operating System (Windows or Mac/Linux respectively).
ls -ltrh total 824 -rw-r--r--@ 1 c2ctech staff 43B Jul 18 07:10 main.rs -rwxr-xr-x 1 c2ctech staff 407K Jul 18 07:49 main
![How to fix ZSH No such File or Directory when running Rust Program How to fix ZSH No such File or Directory when running Rust Program](https://code2care.org/rust/fix-no-such-file-or-directory-main-rust-zsh/images/How to fix ZSH No such File or Directory when running Rust Program.jpg)
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Rust,
- Rust: Cargo Init vs Cargo New Command
- Rust: Write and Run Hello World! Program Example
- How to Split a String using Rust Language
- How to Sort a Vector in Rust with Examples
- Fix: error: could not find `Cargo.toml` in Users or any parent directory
- How to uninstall Rust Language from Mac/Linux/Ubuntu
- How to update Cargo (Rust Lang)
- Fix: rust-analyzer failed to discover workspace [Visual Studio Code]
- How to install Rust using rustup on macOS/Linux/Ubuntu
- Cargo Watch: To Recompile Rust Project Automatically
- Difference between rustc and cargo build commands
- How to Split a String by Space in Rust
- How to know Rust is Installed on Mac?
- Rust: zsh: no such file or directory: ./main
- How to update Rust on Mac/Linux
- List of Rust Cargo Commands
- How to find version of Cargo in Rust
- Fix: error: mismatched closing delimiter } [Rust]
More Posts:
- ADT quit unexpectedly error on Mac OSX Android Eclipse SDK - Android
- How to Use Snipping Tool on Windows 10/11 to Take Screenshots - Windows
- How to print the key value pairs of a Dictionary in Python - Python
- How to access Trash Folder using Mac Terminal Command - MacOS
- Publish JSON Message to AWS SNS Topic via CLI Example - AWS
- [Solution] Installing Whatsapp There's insufficient space on the device - WhatsApp
- Fix Microsoft Windows Update Error 80072EFE - Microsoft
- How to update Microsoft Excel on Mac - Windows