简体   繁体   中英

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. I am trying to install build-essential, but I get a dependency issue. Upon trying to resolve with sudo apt-get install -f, I run into another error that doesn't make much sense. I've tried update and upgrade, but that didn't work either. 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

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; ip6t_HL.h, and ip6t_hl.h. After placing ip6t_HL.h, it attempts to rename ip6t_hl.h.dpkg-new to ip6t_hl.h. The system call to rename the file fails, claiming that ip6t_hl.h already exists

On a "real" linux system, ip6t_HL.h and ip6t_hl.h would clearly be different files. Under WSL they probably had some strange incompatibilities to work out between NTFS's default case insensitive FS and unix's default case sensitivity.

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

strace output:

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.

Here is a workaround, assuming that the package has name 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. Hope this helps, cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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