Geany is an Integrated Development Environment (IDE) that is easy to install on Debian and to configure for use with our Rust projects. To install it:
$ sudo apt install geany
To begin a new project named "greet" in the directory "~/projects/RUST/greet", click on "Project"/"New", and in the box that appears, put "greet" in the "Name:" field, and make the "Filename:" something like :~/projects/RUST/greet/greet.geany" and the "Base path:" something like "~/projects/RUST/greet/". Allow it to create directories as needed.
Then in the bottom left corner, where you have options like "Status" and "Compiler" and "Terminal", select "Terminal". This will open a terminal in the bottom-right pane. Click in that pane and cd to "~/projects/RUST":
$ cd ~/projects/RUST
Normally, using Rust's "cargo" utility, at this point you'd create a new project with cargo new greet
, but Cargo will complain that the directory already exists, an will suggest that you "init' the directory instead with cargo init greet
. Doing this should result in a "greet" directory just as if you had used Cargo to create a new Rust project. The image below should let you see the basics.
(If the "Terminal" button is not visible in the list of buttons (starting with "Status") on the left side, the VTE (Virtual Terminal Emulator) may not be installed. At the time of writing, the runtime files for libvte for GTK3 apps such as Geany can be installed with $ sudo apt install libvte-2.91-0
.)
Now we're ready to open the "main.rs" file with "File"/"Open". Browse to the "~/projects/RUST/greet/src/main.rs" file and open it. It will open in the main pane.
To compile and run this program, you could click on "Build"/"Cargo Run", and the output will be displayed in a newly-opened terminal window. But it'd be nice to just use the mouse on the green arrow button or to press the F5 key, to compile and run it. To do this, we need to modify the Build commands, under "Build"/"Set Build Commands".
In the third section, "Execute Commands", change the "1. Run" option from "./%e" to cargo run, so it looks just like the "2. Cargo Run" option. Now both options do the same thing, but the 2nd one is only available as a "Build" menu option, whereas the first one can be activated with a "Build" menu option or the green arrow button or the F5 key. If you need to provide program arguments, you can just add them behind the "cargo run" you entered, like "cargo run -- --opt1 true --opt2 false".
You can also use the terminal window at the bottom to run normal terminal commands, including cargo commands, like "cargo run". In the image below, you can see both the "Set Build Commands" window, and a "cargo run" in the terminal window. Note that running 'cargo run" from the terminal does not open a different terminal window.
If you want to always display your output to the built-in terminal window instead of a separate terminal window, that's under "Edit"/"Preferences"/ "Terminal", and checking "Execute programs in the VTE".
If you don't set that, wanting to use a separate terminal, but you want to use a different terminal for some reason rather than your Debian box's default terminal, that's under "Edit"/"Preferences"/"Tools"/"Terminal". You can just replace what's there with the name of the teminal you want to use, such as "konsole" or "terminator"; you can also include any options you'd like such as window geomoetry settings to set the size of your window when it opens.
If you get your Geany settings messed up, and want to return to the defaults, just exit out of Geany, and delete your "~/.config/geany" directory.
Hopefully this little tutorial will get you started using Geany as a Rust IDE.