NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.14k stars 14.17k forks source link

dpkg complains about rm missing from path #52987

Closed KiaraGrouwstra closed 4 years ago

KiaraGrouwstra commented 5 years ago

Issue description

The NixOS cheatsheet claims I can install .deb files through a Nix-installed dpkg, but when trying this I encounter some errors.

Steps to reproduce

Example using the .deb for Sogou Pinyin, a popular proprietary Chinese IME:

$ sudo dpkg -i sogoupinyin_2.2.0.0108_amd64.deb
dpkg: error: cannot scan updates directory '/var/lib/dpkg/updates/': No such file or directory
# sure, I'll make you some directories.
$ sudo mkdir -p /var/lib/dpkg/updates/

$ sudo dpkg -i sogoupinyin_2.2.0.0108_amd64.deb
dpkg: error: failed to open package info file '/var/lib/dpkg/status' for reading: No such file or directory
# sure, I can make that.
$ sudo touch /var/lib/dpkg/status

$ sudo dpkg -i sogoupinyin_2.2.0.0108_amd64.deb
dpkg: warning: '/nix/store/dm20hrdk6s4jzfmk1197p2nya0p8fy3a-coreutils-8.29/bin/rm' not found in PATH or not executable
dpkg: warning: '/nix/store/dm20hrdk6s4jzfmk1197p2nya0p8fy3a-coreutils-8.29/bin/diff' not found in PATH or not executable
dpkg: warning: '/nix/store/143saabh5yjfbpwwadvc8hm31khxxrb6-dpkg-1.19.0.5/bin/dpkg-deb' not found in PATH or not executable
dpkg: error: 3 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin

# so, something's wrong with `rm` and the like involving $PATH and those locations? let's check them out.
$ which rm
/run/current-system/sw/bin/rm
# so there's our `rm`. is this in $PATH?
$  echo $PATH
/home/tycho/bin /run/wrappers/bin /home/tycho/.nix-profile/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin /etc/profiles/per-user/tycho/bin
# looks like its folder is! let's check it there?
$  ll /run/current-system/sw/bin/rm
lrwxrwxrwx 15 root root 65 Jan  1  1970 /run/current-system/sw/bin/rm -> /nix/store/dm20hrdk6s4jzfmk1197p2nya0p8fy3a-coreutils-8.29/bin/rm
# we know that place from the error trace. let's check that?
$ ll /nix/store/dm20hrdk6s4jzfmk1197p2nya0p8fy3a-coreutils-8.29/bin/rm
lrwxrwxrwx 1 root root 9 Jan  1  1970 /nix/store/dm20hrdk6s4jzfmk1197p2nya0p8fy3a-coreutils-8.29/bin/rm -> coreutils
# it points to coreutils? I'm confused how that works.
$ coreutils
Try 'coreutils --help' for more information.
$ coreutils --help
Usage: coreutils --coreutils-prog=PROGRAM_NAME [PARAMETERS]... 
...

At this point I'm feeling confused what's going on here and what the errors might be going on about, as well as why I haven't seen similar reports here despite dpkg used apparently having been tried.

Technical details

peterhoeg commented 5 years ago

It's probably not what you want to hear, but if I were you I would write a proper derivation for this package and then use dpkg -x to unpack it and shift the various parts into place.

It does look like dpkg in nix is broken - you do have a valid point, but I doubt this particular use case sees a lot of real life action so it is unlikely to be well maintained.

KiaraGrouwstra commented 5 years ago

Thanks for the suggestion -- that does actually seem helpful. As this particular package is proprietary, I feared making a native package would be a problem. Now that you mention it though, it does seem like other packages pulled this off as well. I'll look into this route. Thank you!

(If any Chinese NixOS users are reading this and have suggestions on how to deal with Chinese IMEs in NixOS, I'd love to hear them!)

peterhoeg commented 5 years ago

Even if the dpkg -i ./some_file.deb part worked as planned, the binary would be unlikely to work unless you use patchelf on it, so then we're back to "might as well do a proper derivation" territory...

As this particular package is proprietary, I feared making a native package would be a problem.

We have lots of proprietary stuff in nixpkgs - that shouldn't be an issue. If the source .deb isn't publicly available on the internet for downloading, you can take a look at how making the source package available for the citrix receiver is handled in nixpkgs .

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
peterhoeg commented 4 years ago

I have updated the wiki.