EnvFile icon indicating copy to clipboard operation
EnvFile copied to clipboard

Support for Rust in IntelliJ & CLion

Open mguillemot-tel opened this issue 5 years ago ā€¢ 7 comments

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.

mguillemot-tel avatar Nov 19 '18 06:11 mguillemot-tel

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.

evanjs avatar Sep 28 '19 19:09 evanjs

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.

evanjs avatar Dec 05 '19 21:12 evanjs

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 ?

pkral78 avatar Feb 26 '20 16:02 pkral78

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.

evanjs avatar Feb 27 '20 00:02 evanjs

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
image

kurtbuilds avatar Jul 05 '23 18:07 kurtbuilds

Support for RustRover would be great as well šŸ‘

The above plugin works, but still šŸ˜€

SimenB avatar Nov 21 '23 07:11 SimenB

It works for run configurations, but not debug ones šŸ™

SimenB avatar Nov 23 '23 08:11 SimenB