EnvFile
EnvFile copied to clipboard
Support for Rust in IntelliJ & CLion
Since the Rust plugin is now officially supported by JetBrains for IntelliJ and CLion, it would be super-nice to have EnvFile support for the Cargo commands added by this plugin.
Was going to answer @ashald's question re CLion support, but I figured it'd be more appropriate to answer it here
I am very interested in utilizing this for my Rust projects with CLion.
I use NixOS, and in the past, I have used nix-shell
to import required development libraries, though I now use direnv to automatically load and cache any dependencies when entering project directories.
Unfortunately, this means that, while I often use CLion for development, I cannot simply stick to the run configurations within CLion, as the direnv environments are not loaded, and I must sometimes, for example, build the project first in a terminal (with the loaded direnv environment or nix-shell dependencies), after which it can be run or watched from CLion.
To illustrate the frequency of linking native libraries in Rust apps, the best example I can think of is anything with network connectivity, which typically needs openssl
, which needs pkgconfig
when building Rust apps, etc...
On NixOS, this means that any Rust app that needs network access must first be built in an environment such as nix-shell -p openssl.dev pkgconfig
, etc (libraries are not available on a system level/scope by default).
TL;DR - I'd like to integrate direnv
and similar env-loaders with my Rust projects via CLion, and this plugin looks like it might help.
I am now using lorri, but things works largely the same as direnv on the client side, e.g. with the direnv plugin for emacs, lorri seems to work flawlessly.
I still have to open a terminal and navigate to a direnv/lorri enabled directory and launch my IDE from there if I want to utilize these environments in CLion, however.
Are there any particular blockers that can be investigated or work that can be done to further this issue?
After investigating WebStorm compatability, I started to wonder if there are any issues for CLion like there are for the node.js plugin, or other items that can be investigated/others might be able to help with.
I still have to open a terminal and navigate to a direnv/lorri enabled directory and launch my IDE from there if I want to utilize these environments in CLion, however.
But it is then impossible to open multiple CLion project with different environments at same time right ?
I still have to open a terminal and navigate to a direnv/lorri enabled directory and launch my IDE from there if I want to utilize these environments in CLion, however.
But it is then impossible to open multiple CLion project with different environments at same time right ?
Correct; Iām then locked to one ENV per instance of the program, and it might even launch with the wrong project loaded, etc.
I figured out a workaround that appears to work seamlessly.
I built a cargo subcommand that loads dotenv files: https://crates.io/crates/cargo-dotenv
I then configured the cargo
commands in IntelliJ to use that subcommand.
cargo install cargo-dotenv
Support for RustRover would be great as well š
The above plugin works, but still š
It works for run configurations, but not debug ones š