简体   繁体   English

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

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

I was excited to use bash on windows but quickly ran into an issue. 我很高兴在Windows上使用bash,但很快遇到了问题。 I am trying to install build-essential, but I get a dependency issue. 我正在尝试安装build-essential,但是遇到依赖项问题。 Upon trying to resolve with sudo apt-get install -f, I run into another error that doesn't make much sense. 尝试使用sudo apt-get install -f解决时,我遇到了另一个没有太大意义的错误。 I've tried update and upgrade, but that didn't work either. 我已经尝试过更新和升级,但是那也不起作用。 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)

Full log of what led to the error in Bash on Ubuntu on Windows terminal is here: https://pastebin.com/dq2D2Gtz 在Windows终端上的Ubuntu上导致Bash错误的原因的完整日志在这里: https : //pastebin.com/dq2D2Gtz

I don't have a solution, but I see the root of the problem. 我没有解决方案,但是我看到了问题的根源。 It seems to have to do with case sensitivity on the filesystem. 这似乎与文件系统的区分大小写有关。 The package for linux-libc-dev puts two copies of a file in /usr/include/linux/netfilter_ipv6 with only a difference in case; linux-libc-dev软件包将文件的两个副本放在/ usr / include / linux / netfilter_ipv6中,只是大小写不同。 ip6t_HL.h, and ip6t_hl.h. ip6t_HL.h和ip6t_hl.h。 After placing ip6t_HL.h, it attempts to rename ip6t_hl.h.dpkg-new to ip6t_hl.h. 放置ip6t_HL.h之后,它将尝试将ip6t_hl.h.dpkg-new重命名为ip6t_hl.h。 The system call to rename the file fails, claiming that ip6t_hl.h already exists 重命名文件的系统调用失败,声称ip6t_hl.h已经存在

On a "real" linux system, ip6t_HL.h and ip6t_hl.h would clearly be different files. 在“实际” Linux系统上,ip6t_HL.h和ip6t_hl.h显然是不同的文件。 Under WSL they probably had some strange incompatibilities to work out between NTFS's default case insensitive FS and unix's default case sensitivity. 在WSL下,它们可能在NTFS的默认不区分大小写FS和UNIX的默认不区分大小写之间存在一些奇怪的不兼容性。

You can duplicate the problem by hand eg, with 您可以手动复制问题,例如

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

mv: cannot move 'foo.h-new' to 'foo.h': File exists mv:无法将“ foo.h-new”移动到“ foo.h”:文件存在

strace output: 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

I had the same problem. 我有同样的问题。 Like @dmattp I found that it this is because, unfortunately, the package contains some (header) files with names that are distinct only by letter case, and that the wonderful WSL file system has an inconsistency regarding case sensitiveness. 像@dmattp一样,我发现这是因为,不幸的是,该软件包包含一些名称仅由字母大小写区分的(头)文件,并且精美的WSL文件系统在区分大小写方面存在不一致之处。

Here is a workaround, assuming that the package has name linux-libc-dev_3.13.0-123.172_amd64.deb : 假设此软件包的名称为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

It says dependencies aren't being installed, so try: 它说没有安装依赖项,所以请尝试:

sudo apt-get install linux-libc-dev

If that doesn't work try: 如果这样不起作用,请尝试:

sudo apt-get install --reinstall build-essential

This will reinstall build-essential. 这将重新安装build-essential. Hope this helps, cheers! 希望这会有所帮助,加油!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM