我尝试在 ubuntu 17.10 上安装 KVM 并出现此错误:
**anuragabhi@abhishek-Notebook:~$** sudo aptitude install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
[sudo] password for anuragabhi:
The following NEW packages will be installed:
at{a} augeas-lenses{a} bridge-utils dctrl-tools{a} debootstrap{a} devscripts{a} dmeventd{a} dput{a} ebtables{a} ipxe-qemu{a}
kpartx{a} libaugeas0{a} libb-hooks-endofscope-perl{a} libboost-random1.62.0{a} libboost-regex1.62.0{a} libcacard0{a}
libclass-method-modifiers-perl{a} libclass-xsaccessor-perl{a} libdata-optlist-perl{a} libdevel-globaldestruction-perl{a}
libdevmapper-event1.02.1{a} libdistro-info-perl{a} libfdt1{a} libfile-chdir-perl{a} libfile-homedir-perl{a} libfile-which-perl{a}
libgetopt-long-descriptive-perl{a} libgit-wrapper-perl{a} libibverbs1{a} libimport-into-perl{a} libio-stringy-perl{a} libiscsi7{a}
liblist-compare-perl{a} liblvm2app2.2{a} liblvm2cmd2.02{a} libmodule-implementation-perl{a} libmodule-runtime-perl{a}
libmoo-perl{a} libnamespace-clean-perl{a} libnetcf1{a} libnumber-compare-perl{a} libnumber-range-perl{a} libpackage-stash-perl{a}
libpackage-stash-xs-perl{a} libparams-classify-perl{a} libparams-util-perl{a} libparams-validate-perl{a}
libpath-iterator-rule-perl{a} libpath-tiny-perl{a} libpod-constants-perl{a} librados2{a} librbd1{a} libreadline5{a}
librole-tiny-perl{a} libsort-key-perl{a} libsort-versions-perl{a} libspice-server1{a} libstrictures-perl{a}
libstring-copyright-perl{a} libstring-escape-perl{a} libsub-exporter-perl{a} libsub-exporter-progressive-perl{a}
libsub-identify-perl{a} libsub-install-perl{a} libsub-quote-perl{a} libtext-glob-perl{a} libtry-tiny-perl{a}
libunicode-utf8-perl{a} libusbredirparser1{a} libvariable-magic-perl{a} libvirt-bin libvirt-clients{a} libvirt-daemon{a}
libvirt-daemon-system{a} libvirt0{a} libxen-4.9{a} libxenstore3.0{a} libxml2-utils{a} licensecheck{a} lvm2{a} python-cheetah{a}
python-libvirt{a} python-vm-builder{a} python3-magic{a} python3-unidiff{a} qemu-block-extra{a} qemu-kvm qemu-system-common{a}
qemu-system-x86{a} qemu-utils{a} seabios{a} sharutils{a} ubuntu-vm-builder wdiff{a}
The following partially installed packages will be configured:
install-info
0 packages upgraded, 94 newly installed, 0 to remove and 49 not upgraded.
Need to get 0 B/21.4 MB of archives. After unpacking 91.9 MB will be used.
Do you want to continue? [Y/n/?] y
Extracting templates from packages: 100%
Preconfiguring packages ...
Setting up install-info (6.4.90.dfsg.1-1build1) ...
/usr/sbin/update-info-dir: 3: /etc/environment: $: not found
dpkg: error processing package install-info (--configure):
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)
Setting up install-info (6.4.90.dfsg.1-1build1) ...
/usr/sbin/update-info-dir: 3: /etc/environment: $: not found
dpkg: error processing package install-info (--configure):
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
install-info
为了解决 DPKG 错误,我尝试了链接中给出的解决方案:
E: 子进程 /usr/bin/dpkg 返回错误代码 (1) [与 Google Chrome 相关]
但似乎没有什么效果。
我尝试了一些命令,输出如下:
anuragabhi@abhishek-Notebook:~$ cat /usr/sbin/update-info-dir
#!/bin/sh
# update-info-dir
# create a dir file from all installed info files
# Copyright 2009, 2014 Norbert Preining
# GPLv2
unset LANGUAGE
unset LANG
if [ -r /etc/environment ] ; then
. /etc/environment
fi
if [ -r /etc/default/locale ] ; then
. /etc/default/locale
fi
Help ()
{
echo "\
SYNOPSIS: update-info-dir [-h,--help] [info-directory]
(re-)creates the index of available documentation in info format
(the file /usr/share/info/dir) which is usually presented by info
browsers
on startup."
exit 0
}
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
Help
fi
if [ -n "$1" ] ; then
INFODIR="$1"
fi
if [ ! -d "$INFODIR" ] ; then
echo "Not a directory: $INFODIR." >&2
exit 1
fi
if [ -r "$INFODIR/dir" ] ; then
rm -f "$INFODIR/dir.old"
cp $INFODIR/dir $INFODIR/dir.old
fi
# we have to remove the dir file not make install-info being surprised
rm -f "$INFODIR/dir"
errors=0
find "$INFODIR" -type f | while read file ; do
case $file in
*/dir|*/dir.gz|*/dir.old|*/dir.old.gz|*-[0-9]|*-[0-9].gz|*-[1-9]
[0-9]|*-[1-9][0-9].gz|*.png|*.jpg)
# these files are ignored
continue
;;
*)
install-info "$file" "$INFODIR/dir" || {
errors=$((errors+1))
}
;;
esac
done
if [ $errors -gt 0 ] ; then
exec >&2
echo
echo "Updating the index of info documentation produced $errors
errors."
fi
exit 0
# vim:set expandtab tabstop=2: #
和:
anuragabhi@abhishek-Notebook:~$ cat /etc/environment
PATH="
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/g a
mes:/usr/local/games"
$ cat >> etc/environment <<EOL
JAVA_HOME=/usr/bin/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL
答案1
第一个错误信息说明了一切:/usr/sbin/update-info-dir: 3: /etc/environment: $: not found
。如您所见,该update-info-dir
脚本仅使用/etc/environment
作为它的参数.
(.
也是bash
命令source
)来在当前进程的环境中设置一些参数。
在我的 Ubuntu 16.04.4 系统(YMMV)上,它包含的初始设置PATH
,这是一个非常重要的变量。PATH
是用于搜索可执行文件的冒号分隔的目录列表bash
。
您可以修复您的问题:
/usr/bin/sudo /bin/rm /etc/environment
echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" | /usr/bin/sudo /usr/bin/tee /etc/environment'
/bin/chmod 0644 /etc/environment