Nixpkgs: bash-completion 2.9 breaks packages installing custom completions

Created on 22 Oct 2019  路  10Comments  路  Source: NixOS/nixpkgs

Describe the bug
A clear and concise description of what the bug is.

dconf tries to write to the bash-completion store path.

glibPreInstallPhase
installing
install flags: install
[0/1] Installing files.
Traceback (most recent call last):
  File "/nix/store/8vaf7gf7ryzb2inm1zksncfchxc3w9kz-meson-0.51.2/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 127, in run
    return options.run_func(options)
  File "/nix/store/8vaf7gf7ryzb2inm1zksncfchxc3w9kz-meson-0.51.2/lib/python3.7/site-packages/mesonbuild/minstall.py", line 514, in run
    installer.do_install(datafilename)
  File "/nix/store/8vaf7gf7ryzb2inm1zksncfchxc3w9kz-meson-0.51.2/lib/python3.7/site-packages/mesonbuild/minstall.py", line 346, in do_install
    self.install_data(d)
  File "/nix/store/8vaf7gf7ryzb2inm1zksncfchxc3w9kz-meson-0.51.2/lib/python3.7/site-packages/mesonbuild/minstall.py", line 376, in install_data
    self.do_copyfile(fullfilename, outfilename)
  File "/nix/store/8vaf7gf7ryzb2inm1zksncfchxc3w9kz-meson-0.51.2/lib/python3.7/site-packages/mesonbuild/minstall.py", line 257, in do_copyfile
    shutil.copyfile(from_file, to_file)
  File "/nix/store/zdh16dcvjw99ybam59zd2ijb6bx138j0-python3-3.7.5/lib/python3.7/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9/share/bash-completion/completions/dconf'
Installing service/dconf-service to /nix/store/0lmxp0r0973cg887pz2wnhgqipk6kpfw-dconf-0.34.0-lib/libexec
Installing gsettings/libdconfsettings.so to /nix/store/0lmxp0r0973cg887pz2wnhgqipk6kpfw-dconf-0.34.0-lib/lib/gio/modules
Installing client/libdconf.so.1.0.0 to /nix/store/0lmxp0r0973cg887pz2wnhgqipk6kpfw-dconf-0.34.0-lib/lib
Installing bin/dconf to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/bin
Installing docs/dconf-service.1 to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/share/man/man1
Installing docs/dconf.1 to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/share/man/man1
Installing docs/dconf.7 to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/share/man/man7
Installing /build/dconf-0.34.0/common/dconf-changeset.h to /nix/store/w14sl1abahj4msb5xrasrg7kpyip1xqw-dconf-0.34.0-dev/include/dconf/common
Installing /build/dconf-0.34.0/common/dconf-enums.h to /nix/store/w14sl1abahj4msb5xrasrg7kpyip1xqw-dconf-0.34.0-dev/include/dconf/common
Installing /build/dconf-0.34.0/common/dconf-paths.h to /nix/store/w14sl1abahj4msb5xrasrg7kpyip1xqw-dconf-0.34.0-dev/include/dconf/common
Installing /build/dconf-0.34.0/client/dconf.h to /nix/store/w14sl1abahj4msb5xrasrg7kpyip1xqw-dconf-0.34.0-dev/include/dconf
Installing /build/dconf-0.34.0/client/dconf-client.h to /nix/store/w14sl1abahj4msb5xrasrg7kpyip1xqw-dconf-0.34.0-dev/include/dconf/client
Installing /build/dconf-0.34.0/build/service/ca.desrt.dconf.service to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/share/dbus-1/services
Installing /build/dconf-0.34.0/build/meson-private/dconf.pc to /nix/store/0lmxp0r0973cg887pz2wnhgqipk6kpfw-dconf-0.34.0-lib/lib/pkgconfig
Installing /build/dconf-0.34.0/client/dconf.vapi to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/share/vala/vapi
Installing /build/dconf-0.34.0/client/dconf.deps to /nix/store/clxwl76pphjw7d67f8f119r6ijyqj2kb-dconf-0.34.0/share/vala/vapi
Installing /build/dconf-0.34.0/bin/completion/dconf to /nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9/share/bash-completion/completions
FAILED: meson-install
/nix/store/8vaf7gf7ryzb2inm1zksncfchxc3w9kz-meson-0.51.2/bin/meson install --no-rebuild
ninja: build stopped: subcommand failed.
builder for '/nix/store/3m79ll8z72w1zprgp9qcad2qvxyvb996-dconf-0.34.0.drv' failed with exit code 1
error: build of '/nix/store/3m79ll8z72w1zprgp9qcad2qvxyvb996-dconf-0.34.0.drv' failed

https://hydra.nixos.org/build/103951665

Note that bash-completions was updated in 12fd773ff058755237ebafe5f1c0bdd36f385eb6.

cc @jtojnar @jonringer

To Reproduce
Steps to reproduce the behavior:

  1. checkout staging
  2. nix-build -A gnome3.dconf

Maintainer information:
```yaml

a list of nixpkgs attributes affected by the problem

attribute: gnome3.dconf

bug blocker GNOME

Most helpful comment

@inigomartinez鈥檚 PR looks fine to me.

Here is a diff between bash-completion.pc built from https://github.com/scop/bash-completion/commit/aa5b46e245013bef9a30c34a7a226779320dc6ee with the revert patch and https://github.com/scop/bash-completion/commit/42837bc5df1c31aa2b79a9838d1b1c9c8d04d9f6:

--- /nix/store/agd6rdgrfjj93sjrwl6x5a7kg5ayzn16-bash-completion-2.9/share/pkgconfig/bash-completion.pc
+++ /home/jtojnar/Projects/nixpkgs/result/share/pkgconfig/bash-completion.pc
@@ -1,7 +1,10 @@
-prefix=/nix/store/agd6rdgrfjj93sjrwl6x5a7kg5ayzn16-bash-completion-2.9
-compatdir=${prefix}/etc/bash_completion.d
-completionsdir=${prefix}/share/bash-completion/completions
-helpersdir=${prefix}/share/bash-completion/helpers
+prefix=/nix/store/z5jbdz0g2ipjpajm1j6s08hf2wi7lg9n-bash-completion-2.9
+datadir=/nix/store/z5jbdz0g2ipjpajm1j6s08hf2wi7lg9n-bash-completion-2.9/share
+sysconfdir=/nix/store/z5jbdz0g2ipjpajm1j6s08hf2wi7lg9n-bash-completion-2.9/etc
+
+compatdir=${sysconfdir}/bash_completion.d
+completionsdir=${datadir}/bash-completion/completions
+helpersdir=${datadir}/bash-completion/helpers

 Name: bash-completion
 Description: programmable completion for the bash shell

All 10 comments

Thanks for letting me know. Looks like bash-completion started hardcoding paths in the pkg-config file, so packages can no longer override the prefix in their build scripts:

--- /nix/store/a16siql5gxj5hcl763fn4krg1w4266px-bash-completion-2.8/share/pkgconfig/bash-completion.pc
+++ /nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9/share/pkgconfig/bash-completion.pc
@@ -1,9 +1,9 @@
-prefix=/nix/store/a16siql5gxj5hcl763fn4krg1w4266px-bash-completion-2.8
-compatdir=${prefix}/etc/bash_completion.d
-completionsdir=${prefix}/share/bash-completion/completions
-helpersdir=${prefix}/share/bash-completion/helpers
+prefix=/nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9
+compatdir=/nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9/etc/bash_completion.d
+completionsdir=/nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9/share/bash-completion/completions
+helpersdir=/nix/store/sqxcg0fssrc36kx8kfgmnrw52mkq4zb3-bash-completion-2.9/share/bash-completion/helpers

 Name: bash-completion
 Description: programmable completion for the bash shell
 URL: https://github.com/scop/bash-completion
-Version: 2.8
+Version: 2.9

We could use

PKG_CONFIG_BASH_COMPLETION_COMPLETIONSDIR= "${placeholder "out"}/share/bash-completion/completions";

in dconf package to bypass this but there will probably be many similarly broken packages.

Or we patch bash-completions to restore prefix? Potential fix https://github.com/scop/bash-completion/pull/344

061c6b8 is in staging-next, so closing.

I'm sorry to say that this MR doesn't fully fix the issue regarding pkg-config files. Previous and new versions generate a pkg-config file with absolute paths on it and this doesn't allow the use of the define-variable option present in pkg-config program.

To be able to do this, datadir and sysconfdir variables must be present in the .pc file, and compatdir, completionsdir and helpersdir be relative to this variables, so earlier variables can be redefined modifying the final destination of the latter variables. This approach is present in #344.

@inigomartinez I really am not the right person for the details, but if a change in the package does not allow us to build it anymore and does not seem to offer us what is needed, then we undo it.

@FRidh I'm sorry if I questioned this procedure. I also agree with you about undoing a change that makes you not to build it anymore.

What I meant to say is that there is a different approach which, in addition to solving the build problem, also solves another problem present in some gnome packages.

I think I actually tried your original PR and it did not work but I am not sure anymore. As soon as your change is merged upstream we will for sure notice on the next release.

Thanks for testing it. I tried it locally and it seems to be correct. This is how bash-completion.pc is generated in upstream:

prefix=/usr/local
compatdir=/usr/local/etc/bash_completion.d
completionsdir=/usr/local/share/bash-completion/completions
helpersdir=/usr/local/share/bash-completion/helpers

Name: bash-completion
Description: programmable completion for the bash shell
URL: https://github.com/scop/bash-completion
Version: 2.9

And this is the resulting file after the change:

prefix=/usr/local
datadir=/usr/local/share
sysconfdir=/usr/local/etc

compatdir=${sysconfdir}/bash_completion.d
completionsdir=${datadir}/bash-completion/completions
helpersdir=${datadir}/bash-completion/helpers

Name: bash-completion
Description: programmable completion for the bash shell
URL: https://github.com/scop/bash-completion
Version: 2.9

Thanks to this, anyone can override datadir and sysconfdir to avoid the installation on directories without write permission. (This can also be done overriding prefix that is present in the file, but that would hardcode the datadir and sysconfdir directories under prefix).

I hope I haven't overlooked something so, please feel free to make any suggestion.

@inigomartinez鈥檚 PR looks fine to me.

Here is a diff between bash-completion.pc built from https://github.com/scop/bash-completion/commit/aa5b46e245013bef9a30c34a7a226779320dc6ee with the revert patch and https://github.com/scop/bash-completion/commit/42837bc5df1c31aa2b79a9838d1b1c9c8d04d9f6:

--- /nix/store/agd6rdgrfjj93sjrwl6x5a7kg5ayzn16-bash-completion-2.9/share/pkgconfig/bash-completion.pc
+++ /home/jtojnar/Projects/nixpkgs/result/share/pkgconfig/bash-completion.pc
@@ -1,7 +1,10 @@
-prefix=/nix/store/agd6rdgrfjj93sjrwl6x5a7kg5ayzn16-bash-completion-2.9
-compatdir=${prefix}/etc/bash_completion.d
-completionsdir=${prefix}/share/bash-completion/completions
-helpersdir=${prefix}/share/bash-completion/helpers
+prefix=/nix/store/z5jbdz0g2ipjpajm1j6s08hf2wi7lg9n-bash-completion-2.9
+datadir=/nix/store/z5jbdz0g2ipjpajm1j6s08hf2wi7lg9n-bash-completion-2.9/share
+sysconfdir=/nix/store/z5jbdz0g2ipjpajm1j6s08hf2wi7lg9n-bash-completion-2.9/etc
+
+compatdir=${sysconfdir}/bash_completion.d
+completionsdir=${datadir}/bash-completion/completions
+helpersdir=${datadir}/bash-completion/helpers

 Name: bash-completion
 Description: programmable completion for the bash shell
Was this page helpful?
0 / 5 - 0 ratings

Related issues

retrry picture retrry  路  3Comments

spacekitteh picture spacekitteh  路  3Comments

matthiasbeyer picture matthiasbeyer  路  3Comments

lverns picture lverns  路  3Comments

grahamc picture grahamc  路  3Comments