簡體   English   中英

Windows上的Ubuntu上的Bash不能使用`sudo apt-get install <packagename> `

[英]Bash on Ubuntu on Windows can't use `sudo apt-get install <packagename>`

我很高興在Windows上使用bash,但很快遇到了問題。 我正在嘗試安裝build-essential,但是遇到依賴項問題。 嘗試使用sudo apt-get install -f解決時,我遇到了另一個沒有太大意義的錯誤。 我已經嘗試過更新和升級,但是那也不起作用。 F

barzevp@UK-LT-8356:~$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies.
 libc6-dev : Depends: linux-libc-dev but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
barzevp@UK-LT-8356:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libfreetype6 os-prober
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-libc-dev
The following NEW packages will be installed
  linux-libc-dev
0 to upgrade, 1 to newly install, 0 to remove and 43 not to upgrade.
5 not fully installed or removed.
Need to get 0 B/767 kB of archives.
After this operation, 3,946 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 28660 files and directories currently installed.)
Preparing to unpack .../linux-libc-dev_3.13.0-123.172_amd64.deb ...
Unpacking linux-libc-dev:amd64 (3.13.0-123.172) ...
dpkg: error processing archive /var/cache/apt/archives/linux-libc-dev_3.13.0-123.172_amd64.deb (--unpack):
 unable to install new version of /usr/include/linux/netfilter_ipv6/ip6t_hl.h': File exists
E: Sub-process /usr/bin/dpkg returned an error code (1)

在Windows終端上的Ubuntu上導致Bash錯誤的原因的完整日志在這里: https : //pastebin.com/dq2D2Gtz

我沒有解決方案,但是我看到了問題的根源。 這似乎與文件系統的區分大小寫有關。 linux-libc-dev軟件包將文件的兩個副本放在/ usr / include / linux / netfilter_ipv6中,只是大小寫不同。 ip6t_HL.h和ip6t_hl.h。 放置ip6t_HL.h之后,它將嘗試將ip6t_hl.h.dpkg-new重命名為ip6t_hl.h。 重命名文件的系統調用失敗,聲稱ip6t_hl.h已經存在

在“實際” Linux系統上,ip6t_HL.h和ip6t_hl.h顯然是不同的文件。 在WSL下,它們可能在NTFS的默認不區分大小寫FS和UNIX的默認不區分大小寫之間存在一些奇怪的不兼容性。

您可以手動復制問題,例如

echo hi > foo.H
echo hi > foo.h-new
mv foo.h-new foo.h

mv:無法將“ foo.h-new”移動到“ foo.h”:文件存在

strace輸出:

rename("/usr/include/linux/netfilter_ipv6/ip6t_HL.h.dpkg-new", "/usr/include/linux/netfilter_ipv6/ip6t_HL.h") = 0
open("/usr/include/linux/netfilter_ipv6/ip6t_hl.h.dpkg-new", O_WRONLY) = 10
fsync(10)                               = 0
close(10)                               = 0
rename("/usr/include/linux/netfilter_ipv6/ip6t_hl.h.dpkg-new", "/usr/include/linux/netfilter_ipv6/ip6t_hl.h") = -1 EEXIST (File exists)
write(2, "dpkg: error processing archive /"..., 199dpkg: error processing archive /var/cache/apt/archives/linux-libc-dev_4.4.0-98.121_amd64.deb (--install):
 unable to install new version of '/usr/include/linux/netfilter_ipv6/ip6t_hl.h': File exists
) = 199

我有同樣的問題。 像@dmattp一樣,我發現這是因為,不幸的是,該軟件包包含一些名稱僅由字母大小寫區分的(頭)文件,並且精美的WSL文件系統在區分大小寫方面存在不一致之處。

假設此軟件包的名稱為linux-libc-dev_3.13.0-123.172_amd64.deb ,這是一種解決方法:

cd any-temp-dir

apt-get download linux-libc-dev
ar x linux-libc-dev_3.13.0-123.172_amd64.deb
tar xJf data.tar.xz # ignore all erors like ./usr/include/linux/netfilter_ipv4/ipt_ttl.h: Cannot open: Input/output error
tar cJf data.tar.xz ./usr
ar rcs linux-libc-dev_3.13.0-123.172_amd64-patched.deb debian-binary control.tar.gz data.tar.xz 

sudo dpkg -i linux-libc-dev_3.13.0-123.172_amd64-patched.deb

它說沒有安裝依賴項,所以請嘗試:

sudo apt-get install linux-libc-dev

如果這樣不起作用,請嘗試:

sudo apt-get install --reinstall build-essential

這將重新安裝build-essential. 希望這會有所幫助,加油!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM