Ubuntu

無法創建目錄權限被拒絕 - 即使使用 sudo

  • September 26, 2021

我正在嘗試安裝gsl-2.5- https://www.gnu.org/software/gsl/。我已經使用了命令sudo ./configure && make && make install,但仍然遇到權限問題:

libtool: link: ranlib .libs/libgsl.a
libtool: link: rm -fr .libs/libgsl.lax .libs/libgsl.lax
libtool: link: ( cd ".libs" && rm -f "libgsl.la" && ln -s "../libgsl.la" "libgsl.la" )
/bin/bash ./libtool  --tag=CC   --mode=link gcc  -g -O2   -o gsl-randist gsl-randist.o libgsl.la cblas/libgslcblas.la -lm 
libtool: link: gcc -g -O2 -o .libs/gsl-randist gsl-randist.o  ./.libs/libgsl.so cblas/.libs/libgslcblas.so -lm
/bin/bash ./libtool  --tag=CC   --mode=link gcc  -g -O2   -o gsl-histogram gsl-histogram.o libgsl.la cblas/libgslcblas.la -lm 
libtool: link: gcc -g -O2 -o .libs/gsl-histogram gsl-histogram.o  ./.libs/libgsl.so cblas/.libs/libgslcblas.so -lm
creating gsl-config
creating gsl.pc
make[2]: Leaving directory '/home/sam/program_files/gsl-2.5'
make[1]: Leaving directory '/home/sam/program_files/gsl-2.5'
Making install in gsl
make[1]: Entering directory '/home/sam/program_files/gsl-2.5/gsl'
make[2]: Entering directory '/home/sam/program_files/gsl-2.5/gsl'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/sam/program_files/gsl-2.5/gsl'
make[1]: Leaving directory '/home/sam/program_files/gsl-2.5/gsl'
Making install in utils
make[1]: Entering directory '/home/sam/program_files/gsl-2.5/utils'
make[2]: Entering directory '/home/sam/program_files/gsl-2.5/utils'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/sam/program_files/gsl-2.5/utils'
make[1]: Leaving directory '/home/sam/program_files/gsl-2.5/utils'
Making install in sys
make[1]: Entering directory '/home/sam/program_files/gsl-2.5/sys'
make[2]: Entering directory '/home/sam/program_files/gsl-2.5/sys'
make[2]: Nothing to be done for 'install-exec-am'.
/bin/mkdir -p '/usr/local/include/gsl'
/bin/mkdir: cannot create directory ‘/usr/local/include/gsl’: Permission denied
Makefile:637: recipe for target 'install-pkgincludeHEADERS' failed
make[2]: *** [install-pkgincludeHEADERS] Error 1
make[2]: Leaving directory '/home/sam/program_files/gsl-2.5/sys'
Makefile:918: recipe for target 'install-am' failed
make[1]: *** [install-am] Error 2
make[1]: Leaving directory '/home/sam/program_files/gsl-2.5/sys'
Makefile:963: recipe for target 'install

我猜,出於某種原因,我的 root 權限不包括該 /usr/local/include目錄。有誰知道為什麼會出現這種情況以及我該如何解決?

你的命令

sudo ./configure && make && make install

依次執行這三個命令:

sudo ./configure
make
make install

請注意,只有第一個具有 root 權限。

通常,您會以自己的使用者帳戶執行配置/製作階段,只為最終安裝階段分配 root 權限:

./configure
make
sudo make install

&&如果你有膽量,你可以加入這些。就我個人而言,我更喜歡將安裝階段作為單獨的活動保留,僅當我很高興前兩個階段不僅成功而且正確地完成時,我才應用它。

引用自:https://unix.stackexchange.com/questions/457465