Why do the "system" and "!" commands not respect my PATH environment variable in Linux?
Ältere Kommentare anzeigen
I am using RHEL 7.9 which has an outdated version of GCC. I have downloaded a more recent version of GCC (9.2.0) and put the installation folder on my PATH environment variable. Even though I have put the installation folder for the newer version of GCC at the front of my PATH environment variable, it seems that MATLAB is still using my old installation of GCC.
The following output from the "getenv" command shows the PATH environment variable with the install location of the new GCC version at the front.
>> getenv PATH
ans = '/usr/local/opt/gcc-9.2.0/bin:/usr/local/bin:/usr/local/MATLAB/R2021b/bin:/bin:/usr/bin'
This command shows that the new version of GCC is installed and exists at the installation directory:
>> !/usr/local/opt/gcc-9.2.0/bin/gcc --version gcc
(GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software;see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
When I try to use the shell escape command to execute the "which gcc" command, it does not seem to pick up the new version of GCC that I have installed:
>> !which gcc
/bin/gcc
As shown in the following shell escape command, the GCC that MATLAB will target is the old version of GCC and not the new one:
>> !gcc --version gcc
(GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I have tried this workflow with the "system" command as well, but it seems to produce the same results.
Is there a way to make MATLAB respect my PATH environment variable and pick up the new version of GCC that I have installed.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!