Open Redrield opened 1 month ago
How does nix/lunarvim interprets cc:gcc
exec $CC
in that case calls cc
I believe (Hard to tell, because they both lead to calling gcc)
That's really confusing though, the convention is for CC
to be a path, and :
is a valid character in the path.
Not sure how lunarvim/nix supports it.
Summary
I use
lunarvim
as my development environment for my work, including Rust projects. A combination of lunarvim on NixOS prefixing theCC
environment variable with the valuecc
, and Nix development environments exportingCC=gcc
leads to an overall environment ofCC=cc:gcc
in Lunarvim. When executing commands in a normal shell, this isn't an issue.exec $CC
withCC=cc:gcc
calls the C compiler correctly. However, given this somewhat bizarre environment in Lunarvim, coupled with the fact that it launches rust-analyzer (which will therefore inherit the environment), I ran into the situation where cc's logic to extract the compiler name from the environment leads to an argv[0] ofcc:gcc
, which is of course incorrect.Minimal reproduction
I've tested this in the cc_env test suite on the latest diff of cc-rs, and the test fails with the following output:
Root cause
The root cause is
:
-delimited lists not being accounted for inBuild::env_tool
(lib.rs 3010:3076).tool
at line 3016 =cc:gcc
, which falls through to the wrapper handling code, leading tomaybe_wrapper = cc:gcc
, which continues to fall through to the final return statement, wherecc:gcc
is returned as the compiler path (.0 of the tuple returned by env_tool).