在 debian 设备上尝试不使用 sudo 安装 git 时,遇到错误:
LINK git-credential-store /usr/bin/ld: 找不到 -lz collect2:错误:ld 返回 1 退出状态 make: *** [Makefile:1991: git-credential-store] 错误 1 当我运行 make.
根据这些答案,问题是没有安装
zlib1g-dev
包。
这些答案中提供的解决方案假定用户具有 sudo 访问权限。他们要么建议跑步:
sudo apt-get install zlib1g-dev
或从 debian 获取
zlib1g-dev
可以通过以下方式完成:
wget https://ftp.de.debian.org/debian/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2+deb11u2_amd64.deb
但是,
dpkg -i
也需要 sudo 权限。因此,我想知道:
如何在没有 sudo 权限的情况下安装
zlib1g-dev
?
要在没有 sudo 的情况下安装 git,我先安装
curl
,然后 expat
然后 zlib
然后 git
.
mkdir -p /home/$(whoami)/install
cd /home/$(whoami)/install
wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar -xf curl-7.47.1.tar.gz
mkdir -p curl_install
cd curl-7.47.1
./configure --prefix=/home/$(whoami)/install/curl_install
make
make install
cd /home/$(whoami)/install
wget http://sourceforge.net/projects/expat/files/expat/2.5.0/expat-2.5.0.tar.gz
tar -xzf expat-2.5.0.tar.gz
mkdir expat_install
cd expat-2.5.0
./configure --prefix=/home/$(whoami)/install/expat_install
make
make install
cd /home/$(whoami)/install
wget https://zlib.net/zlib-1.2.13.tar.gz
tar -xf zlib-1.2.13.tar.gz
mkdir zlib_install
cd zlib-1.2.13
./configure --prefix=/home/$(whoami)/install/zlib_install
make
make install
cd /home/$(whoami)/install
wget https://github.com/git/git/archive/v2.6.4.tar.gz
tar -xf v2.6.4.tar.gz
mkdir git_install
cd /home/$(whoami)/install/git-2.6.4
make configure
./configure --prefix=/home/$(whoami)/install/git_install/git --with-curl=/home/$(whoami)/install/curl --with-expat=/home/$(whoami)/install/expat
make
make install
抛出
git
命令:make
错误;找不到zlib.h
所以我手动复制了这些文件来克服这个错误:
cd /home/$(whoami)/install/git-2.6.4
cp /home/$(whoami)/install/zlib_install/include/zlib.h zlib.h
cp /home/$(whoami)/install/zlib-1.2.13/zconf.h zconf.h
此外,this答案表明
libz.a
和libz.so
文件丢失。 (这些都是zlib-1.2.13
安装的所以我也手动复制了这些在:
cd /home/$(whoami)/install/git-2.6.4
cp /home/$(whoami)/install/zlib-1.2.13/libz.a libz.a
cp /home/$(whoami)/install/zlib-1.2.13/libz.so libz.so
注意,我首先尝试将
/home/$(whoami)/install/zlib_install
和 /home/$(whoami)/install/zlib_install/include/
和 /home/$(whoami)/install/zlib_install/include/zlib.h
添加到路径中(并验证它们在路径中),但是,这并没有使 make
找到 zlib.h
文件。
添加
libz.a
和libz.so
文件不允许make
(对于git
)克服
找不到-lz 错误。
lsb_release -a
的输出是:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster