【问题标题】:Bash on Ubuntu on Windows can't use `sudo apt-get install <packagename>`Windows 上的 Ubuntu 上的 Bash 无法使用 `sudo apt-get install <packagename>`
【发布时间】:2017-07-05 14:00:14
【问题描述】:

我很高兴能在 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

【问题讨论】:

  • 运行“apt-get check”重新构建缓存并重试。
  • @RamanSailopal,刚试过这个,但最终还是会导致同样的错误(未满足的依赖,使用apt-get -f install解决等)
  • 我也有同样的问题,请问你解决了吗?
  • 是的,通过切换到 Ubuntu 16.04 解决了这个问题。现在快乐的日子:)
  • Stack Overflow 是一个编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参阅帮助中心的What topics can I ask about here。也许Super UserUnix & Linux Stack Exchange 会是一个更好的提问地点。

标签: windows bash ubuntu windows-subsystem-for-linux


【解决方案1】:

我没有解决方案,但我看到了问题的根源。它似乎与文件系统上的区分大小写有关。 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

【讨论】:

  • superuser.com 报告了同样的问题,superuser.com/questions/1238903/…
  • 我可以确认您的分析(顺便说一句,请参阅下面的解决方法),但不能确认您涉及 foo.H 的示例。这是我能够重现 WSL 文件系统中关于区分大小写的不一致的一种方法:touch a.txt; touch A.txt 产生 touch: cannot touch 'A.txt': Input/output error
【解决方案2】:

我遇到了同样的问题。就像@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

【讨论】:

  • 感谢分享,我希望这可以帮助其他人解决这个问题。不幸的是,我无法确认这是否能解决问题,因为我已经从那个环境中继续前进,因此无法对其进行测试。
  • 感谢@Barzev 您的迅速反应。同时,我的一位同事在他的 WSL Ubuntu 16.04 安装上测试了我的解决方法。它也可以在那里工作。
【解决方案3】:

它说没有安装依赖项,所以试试:

sudo apt-get install linux-libc-dev

如果这不起作用,请尝试:

sudo apt-get install --reinstall build-essential

这将重新安装build-essential.希望这会有所帮助,干杯!

【讨论】:

  • 这导致了同样的错误链。这是日志结果:pastebin.com/7WXkKByh
  • 执行 sudo apt-get autoremove.. 看看会弹出什么。
  • 同样的问题.. The following packages have unmet dependencies. libc6-dev : Depends: linux-libc-dev but it is not installed E: Unmet dependencies. Try using -f.
猜你喜欢
  • 2014-03-09
  • 1970-01-01
  • 2012-02-21
  • 2011-09-23
  • 2016-07-11
  • 1970-01-01
  • 2022-08-16
  • 2022-01-03
  • 1970-01-01
相关资源
最近更新 更多