Rust: zsh: no such file or directory: ./main


./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,

  1. 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>
  2. 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

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

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap