Subject: bug#47783: 28.0.50; [feature/native-comp] libgccjit.so: error: error invoking gcc driver

From: Pankaj Jangid <[email-masked]>
Date: Sat, 17 Apr 2021 22:27:53 +0530

Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

>> Is there a way in Emacs to get all the environment variables in one
>> go?
>
> One can use the `process-environment' variable. Also might be useful for
> you `initial-environment'.

Finally, as you pointed out, PATH env is the root cause. When I start
from GUI the PATH is set to:

     "/usr/bin:/bin:/usr/sbin:/sbin"

But when I start from CLI, the Bash init files are executed and hence
the PATH is:

    "/Users/pankaj/.sdkman/candidates/kotlin/current/bin:/Users/pankaj/.sdkman/candidates/groovy/current/bin:/Users/pankaj/.sdkman/candidates/gradle/current/bin:/Users/pankaj/.sdkman/candidates/ant/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin:/Users/pankaj/Applications/Emacs.app/Contents/MacOS:/Users/pankaj/Applications/Emacs.app/Contents/MacOS/bin:/Users/pankaj/go/bin:/Users/pankaj/.cargo/bin"

There are lots of things. But the PATH, which we are interested in, is
the location of compiler; and that is "/usr/local/bin". So I hard-coded
PATH in a CLI session:

   export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

And then launched ‘Emacs’ from there. Worked perfectly fine.

So, my question is - is there a way to adjust the ‘initial-environment’
variable? The docstring says that it is inherited from the parent
process. So that makes it kind-of read-only.

Other solution could be to hold-on the compilation till full
‘~/emacs.d/init.el’ (or whichever is the init file) is
evaluated. Because users configure the environment variables during that
process.

--
Regards
Pankaj