Arch Linux编译软件时出现make[4]: gcc: Permission denied错误求助
解决Arch Linux编译R及R包时gcc权限拒绝的问题
这问题我之前帮朋友排查过类似的,核心是子进程调用gcc时找不到正确的可执行文件或者被权限限制拦截,给你几个靠谱的解决方向:
1. 全局指定gcc绝对路径(快速临时解决)
你手动改Makeconf里的CC=/usr/bin/gcc能生效,说明用绝对路径没问题。可以先在终端里导出这个环境变量,让所有后续的make子进程都继承:
export CC=/usr/bin/gcc export CXX=/usr/bin/g++
然后重新运行make编译R,或者编译R包前先执行这两句,就能绕过相对路径调用的问题。
2. 给R包编译配置持久化规则
如果每次编译R包都要手动设置太麻烦,直接修改R的全局编译配置文件:
- 创建或编辑
~/.R/Makevars文件:nano ~/.R/Makevars - 添加以下内容:
CC=/usr/bin/gcc CXX=/usr/bin/g++ FC=/usr/bin/gfortran
保存退出后,所有R包编译都会自动使用这些绝对路径的编译器,不用再单独设置。
3. 排查环境变量被覆盖的问题
有时候编译脚本里的make会重置PATH或者CC变量,导致子进程里的gcc不是你终端里的那个。你可以在报错的目录(比如src/extra/blas)里手动执行:
echo $CC which gcc ls -l $(which gcc)
如果输出的CC不是/usr/bin/gcc,或者which gcc找不到路径,说明编译脚本里的环境被修改了。这时候可以查看项目根目录的configure脚本或者顶级Makefile,看看有没有硬编码修改CC的地方。
4. 检查安全工具拦截
Arch默认没启用SELinux,但如果你装了AppArmor,可能会拦截gcc的调用:
- 检查AppArmor状态:
systemctl status apparmor - 如果是active状态,临时关闭试试:
sudo systemctl stop apparmor
然后重新编译,要是能正常运行,就需要调整AppArmor的规则,允许gcc在编译目录下被调用。
附:你提供的完整错误输出
[cmasso6@cmasso6 R-3.6.3]$ make make[1]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/m4' make[1]: Nothing to be done for 'R'. make[1]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/m4' make[1]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/tools' make[1]: Nothing to be done for 'R'. make[1]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/tools' make[1]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/doc' make[2]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/doc/html' make[2]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/doc/html' make[2]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/doc/manual' make[2]: Nothing to be done for 'R'. make[2]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/doc/manual' make[1]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/doc' make[1]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/etc' make[1]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/etc' make[1]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/share' make[1]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/share' make[1]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src' make[2]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/scripts' creating src/scripts/R.fe make[3]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/scripts' make[3]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/scripts' make[2]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/scripts' make[2]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/include' config.status: creating src/include/config.h config.status: src/include/config.h is unchanged make[3]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/include/R_ext' make[3]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/include/R_ext' make[2]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/include' make[2]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/extra' make[3]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/extra/blas' make[4]: Entering directory '/home/cmasso6/Downloads/R-3.6.3/src/extra/blas' gfortran -fno-optimize-sibling-calls -fpic -g -O2 -c blas.f -o blas.o gfortran -fno-optimize-sibling-calls -fpic -g -O2 -c cmplxblas.f -o cmplxblas.o gcc -shared -fopenmp -L/usr/local/lib64 -o libRblas.so blas.o cmplxblas.o -lgfortran -lm -lquadmath make[4]: gcc: Permission denied make[4]: *** [Makefile:37: libRblas.so] Error 127 make[4]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/extra/blas' make[3]: *** [Makefile:32: R] Error 2 make[3]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/extra/blas' make[2]: *** [Makefile:35: make.blas] Error 2 make[2]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src/extra' make[1]: *** [Makefile:28: R] Error 1 make[1]: Leaving directory '/home/cmasso6/Downloads/R-3.6.3/src' make: *** [Makefile:61: R] Error 1
内容的提问来源于stack exchange,提问作者cmasso6
相关产品推荐
相关产品推荐

