Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapGAppsHook without GST (or GRL): makeWrapper doesn't understand the arg GI_TYPELIB_PATH #75443

Closed
KoviRobi opened this issue Dec 10, 2019 · 8 comments

Comments

@KoviRobi
Copy link
Contributor

KoviRobi commented Dec 10, 2019

wrapGAppsHook dies without GST

When using wrapGAppsHook, and we don't have any GST plugins, I end up with the (pretty-printed) wrapping

wrapProgram \
    /nix/store/b3l3niilvqcxcsbxmd6sgqk1dy1rk81c-pye-menu-1.0/bin/pye_menu_shell \
    --prefix PATH : /nix/store/4c3z5r6yxsf2cxwwyazhdn92xixn4j5b-python3-3.7.5/bin:/nix/store/b3l3niilvqcxcsbxmd6sgqk1dy1rk81c-pye-menu-1.0/bin:/nix/store/y8j1cfj8d9r5rbbxc22w7hnfjw5f4fd3-cairo-1.16.0-dev/bin:/nix/store/6mg7lfbdh9pgx7pbxr3544qqbrigdl1q-freetype-2.10.1-dev/bin:/nix/store/gpszqcy0xi0lavbbjdq82zkkjp3jbp2a-bzip2-1.0.6.0.1-bin/bin:/nix/store/031c5pk5lzabgmpqpyd46hzi625as6bp-libpng-apng-1.6.37-dev/bin:/nix/store/f8kl7kmpv130aw9zm542p74a3hg0yc13-fontconfig-2.12.6-bin/bin:/nix/store/bqp30vkncmm222mjvwggz0s7p318sflj-expat-2.2.7-dev/bin:/nix/store/w57xa8g4s4aviwmqwgra7m5hwj2b005m-glib-2.60.7-dev/bin:/nix/store/v5d4966ahvfir2hwpv003022f3pb7vik-gettext-0.19.8.1/bin:/nix/store/qpvxhl1jr0fxnrx9idnpdagqs00m5m2z-glib-2.60.7/bin \
    --set PYTHONNOUSERSITE true \
    --set GDK_PIXBUF_MODULE_FILE /nix/store/7ddlakx6xjczqbfs80xjd14f30fzadws-gdk-pixbuf-2.38.1/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
    --prefix XDG_DATA_DIRS : /nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/b41z51vdv11n6df8ki5vj8dynxw98f9l-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10 \
    --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : \
    --prefix GI_TYPELIB_PATH : /nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/lib/girepository-1.0:/nix/store/z29l5xaaxh1s0697mcldj71ab0zshry1-librsvg-2.44.15/lib/girepository-1.0:/nix/store/pija1xzm7izxfb5m2hvhvlwp1l38ffxa-gobject-introspection-1.60.2/lib/girepository-1.0 \
    --prefix GRL_PLUGIN_PATH :

(Extracted with preFixup = "set -x" and postFixup = "set +x".)

The problem is that the GST_PLUGIN_SYSTEM_PATH_1_0 has no arguments, which should be passed as "", without the quotes the argument becomes the next --prefix which messes up the parser for makeWrapper. The following seems to work, though

 # in a nix-shell, patching the local file, hence ./pye_menu_shell
 wrapProgram \
     ./pye_menu_shell \
     --prefix PATH : /nix/store/4c3z5r6yxsf2cxwwyazhdn92xixn4j5b-python3-3.7.5/bin:/nix/store/b3l3niilvqcxcsbxmd6sgqk1dy1rk81c-pye-menu-1.0/bin:/nix/store/y8j1cfj8d9r5rbbxc22w7hnfjw5f4fd3-cairo-1.16.0-dev/bin:/nix/store/6mg7lfbdh9pgx7pbxr3544qqbrigdl1q-freetype-2.10.1-dev/bin:/nix/store/gpszqcy0xi0lavbbjdq82zkkjp3jbp2a-bzip2-1.0.6.0.1-bin/bin:/nix/store/031c5pk5lzabgmpqpyd46hzi625as6bp-libpng-apng-1.6.37-dev/bin:/nix/store/f8kl7kmpv130aw9zm542p74a3hg0yc13-fontconfig-2.12.6-bin/bin:/nix/store/bqp30vkncmm222mjvwggz0s7p318sflj-expat-2.2.7-dev/bin:/nix/store/w57xa8g4s4aviwmqwgra7m5hwj2b005m-glib-2.60.7-dev/bin:/nix/store/v5d4966ahvfir2hwpv003022f3pb7vik-gettext-0.19.8.1/bin:/nix/store/qpvxhl1jr0fxnrx9idnpdagqs00m5m2z-glib-2.60.7/bin \
     --set PYTHONNOUSERSITE true \
     --set GDK_PIXBUF_MODULE_FILE /nix/store/7ddlakx6xjczqbfs80xjd14f30fzadws-gdk-pixbuf-2.38.1/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
     --prefix XDG_DATA_DIRS : /nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/b41z51vdv11n6df8ki5vj8dynxw98f9l-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10 \
-     --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : \
+     --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "" \
     --prefix GI_TYPELIB_PATH : /nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/lib/girepository-1.0:/nix/store/z29l5xaaxh1s0697mcldj71ab0zshry1-librsvg-2.44.15/lib/girepository-1.0:/nix/store/pija1xzm7izxfb5m2hvhvlwp1l38ffxa-gobject-introspection-1.60.2/lib/girepository-1.0 \
-     --prefix GRL_PLUGIN_PATH :
+     --prefix GRL_PLUGIN_PATH : ""

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/KoviRobi/Pye-Menu.git
  2. git checkout 49b86e1c716eebdbe344721eec99b77538a430dc
  3. nix-build

On the channel nixos-19.09, with

$ realpath `echo $NIX_PATH|tr : $'\n'|sed -n 's/nixpkgs=//p'`
/nix/store/wrjvn1wysg1y98pr53priyp79di20h7s-nixos-19.09.1548.3a1861fcabc/nixos

and also with

$ realpath /nix/var/nix/profiles/per-user/root/channels/nixos-unstable 
/nix/store/4y71vgg3f6lviag46hkijwxlczjlmj0n-nixos-unstable-20.03pre204199.3140fa89c51/nixos-unstable

Expected behavior
The package builds

Screenshots

these derivations will be built:
  /nix/store/bdhzjppc5zhy552axm38bw3bmrpz7q28-python3.7-pye-menu-1.0.drv
building '/nix/store/bdhzjppc5zhy552axm38bw3bmrpz7q28-python3.7-pye-menu-1.0.drv'...
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing setuptools-check-hook
Using setuptoolsCheckPhase
unpacking sources
unpacking source archive /nix/store/1rw3230c24j5sv1dng5f008kqsn4d01r-pye-menu
source root is pye-menu
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file pye-menu/wacom_menu_example.png
patching sources
configuring
no configure script, doing nothing
building
Executing setuptoolsBuildPhase
running bdist_wheel
running build
running build_py
creating build
creating build/lib
copying pye_menu.py -> build/lib
running build_scripts
creating build/scripts-3.7
copying and adjusting pye_menu_shell -> build/scripts-3.7
changing mode of build/scripts-3.7/pye_menu_shell from 644 to 755
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
copying build/lib/pye_menu.py -> build/bdist.linux-x86_64/wheel
running install_egg_info
running egg_info
writing Pye_Menu.egg-info/PKG-INFO
writing dependency_links to Pye_Menu.egg-info/dependency_links.txt
writing top-level names to Pye_Menu.egg-info/top_level.txt
reading manifest file 'Pye_Menu.egg-info/SOURCES.txt'
writing manifest file 'Pye_Menu.egg-info/SOURCES.txt'
Copying Pye_Menu.egg-info to build/bdist.linux-x86_64/wheel/Pye_Menu-1.0-py3.7.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/Pye_Menu-1.0.data
creating build/bdist.linux-x86_64/wheel/Pye_Menu-1.0.data/scripts
copying build/scripts-3.7/pye_menu_shell -> build/bdist.linux-x86_64/wheel/Pye_Menu-1.0.data/scripts
changing mode of build/bdist.linux-x86_64/wheel/Pye_Menu-1.0.data/scripts/pye_menu_shell to 755
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.linux-x86_64/wheel/Pye_Menu-1.0.dist-info/WHEEL
creating 'dist/Pye_Menu-1.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'pye_menu.py'
adding 'Pye_Menu-1.0.data/scripts/pye_menu_shell'
adding 'Pye_Menu-1.0.dist-info/LICENSE'
adding 'Pye_Menu-1.0.dist-info/METADATA'
adding 'Pye_Menu-1.0.dist-info/WHEEL'
adding 'Pye_Menu-1.0.dist-info/top_level.txt'
adding 'Pye_Menu-1.0.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Finished executing setuptoolsInstallPhase
glibPreInstallPhase
glibPreInstallPhase
installing
Executing pipInstallPhase
/build/pye-menu/dist /build/pye-menu
Processing ./Pye_Menu-1.0-py3-none-any.whl
Installing collected packages: Pye-Menu
Successfully installed Pye-Menu-1.0
/build/pye-menu
Finished executing pipInstallPhase
glibPreFixupPhase
glibPreFixupPhase
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/1xgcj70f24bxh9czafxxa8p3m15z5w2w-python3.7-pye-menu-1.0
strip is /nix/store/q354712mnkw3ky8b5crj7ir7dyv29ylj-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/1xgcj70f24bxh9czafxxa8p3m15z5w2w-python3.7-pye-menu-1.0/lib  /nix/store/1xgcj70f24bxh9czafxxa8p3m15z5w2w-python3.7-pye-menu-1.0/bin
patching script interpreter paths in /nix/store/1xgcj70f24bxh9czafxxa8p3m15z5w2w-python3.7-pye-menu-1.0
checking for references to /build/ in /nix/store/1xgcj70f24bxh9czafxxa8p3m15z5w2w-python3.7-pye-menu-1.0...
Rewriting #!/nix/store/4c3z5r6yxsf2cxwwyazhdn92xixn4j5b-python3-3.7.5/bin/python3.7 to #!/nix/store/4c3z5r6yxsf2cxwwyazhdn92xixn4j5b-python3-3.7.5
wrapping `/nix/store/1xgcj70f24bxh9czafxxa8p3m15z5w2w-python3.7-pye-menu-1.0/bin/pye_menu_shell'...

Builder called die: makeWrapper doesn't understand the arg GI_TYPELIB_PATH
Backtrace:
108 makeWrapper /nix/store/1fgzsay81ncq1mf3608kzjklhikhqp1a-hook/nix-support/setup-hook
152 wrapProgram /nix/store/1fgzsay81ncq1mf3608kzjklhikhqp1a-hook/nix-support/setup-hook
109 wrapPythonProgramsIn /nix/store/agjbw5gdv6ds22arjg4aqn0g89zrarma-hook/nix-support/setup-hook
4 wrapPythonPrograms /nix/store/agjbw5gdv6ds22arjg4aqn0g89zrarma-hook/nix-support/setup-hook
97 _callImplicitHook /nix/store/1zpvvxqxypyx2hlsg4zm7jdh1dc7z7cz-stdenv-linux/setup
116 _eval /nix/store/1zpvvxqxypyx2hlsg4zm7jdh1dc7z7cz-stdenv-linux/setup
45 runHook /nix/store/1zpvvxqxypyx2hlsg4zm7jdh1dc7z7cz-stdenv-linux/setup
1204 fixupPhase /nix/store/1zpvvxqxypyx2hlsg4zm7jdh1dc7z7cz-stdenv-linux/setup
1325 genericBuild /nix/store/1zpvvxqxypyx2hlsg4zm7jdh1dc7z7cz-stdenv-linux/setup
2 main /nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh

builder for '/nix/store/bdhzjppc5zhy552axm38bw3bmrpz7q28-python3.7-pye-menu-1.0.drv' failed with exit code 1
error: build of '/nix/store/bdhzjppc5zhy552axm38bw3bmrpz7q28-python3.7-pye-menu-1.0.drv' failed

(Well, kind of a screenshot.)

Additional context
Might be related, #29055

Workaround
Adding gst plugins, even if the program doesn't depend on it, seems to fix it. Or setting GST_PLUGIN_SYSTEM_PATH_1_0 = ''""'' (the string containing an open/close quote pair, which gets expanded to the empty argument). See
KoviRobi/Pye-Menu@4c95bac

I suspect the proper fix will be in <nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh> e.g. nixos-19.09 or nixos-unstable, but I don't know enough about it to commit a fix knowing that it won't break other stuff

@KoviRobi
Copy link
Contributor Author

KoviRobi commented Dec 10, 2019

EDIT: No, the nixos-unstable channel build has that commit, still breaks

Hmm, trying to link the wrap-gapps-hook.sh file leads me to 22a2168#diff-c90743a6f7cfce0259c1e97010a37bdb which might fix it.

@KoviRobi
Copy link
Contributor Author

KoviRobi commented Dec 10, 2019

Of course, it's also possible that this is due to my misuse/misunderstanding of wrapGAppsHook, I followed the gnome-music example in the manual. But the following seems to fix it, for nixos-unstable. The question is, is this a necessary and good patch?

--- pkgs/build-support/setup-hooks/wrap-gapps-hook.sh   2019-12-10 17:00:45.264978439 +0000
+++ pkgs/build-support/setup-hooks/wrap-gapps-hook.sh.new       2019-12-10 17:00:39.333978461 +0000
@@ -42,7 +42,9 @@
   fi
 
   for v in ${wrapPrefixVariables:-} GST_PLUGIN_SYSTEM_PATH_1_0 GI_TYPELIB_PATH GRL_PLUGIN_PATH; do
-    gappsWrapperArgs+=(--prefix "$v" : "${!v}")
+    if [ -n "${!v}" ]; then
+      gappsWrapperArgs+=(--prefix "$v" : "${!v}")
+    fi
   done
 
   if [[ -z "${dontWrapGApps:-}" ]]; then

I have added this as PR #75450

@jtojnar
Copy link
Member

jtojnar commented Dec 10, 2019

We pass "${gappsWrapperArgs[@]}" directly to wrapProgram:

wrapProgram "$program" "${gappsWrapperArgs[@]}" "$@"

and gappsWrapperArgs is an array, so the empty string should be passed as an argument when the variable does not exist.

And makeWrapper should just skip --prefix with empty value:

I cannot reproduce the issue on master, nixos-unstable, nor do I recall ever seeing such issue. We have lot of packages not depending on GStreamer or Grilo, so I would expect the issue to pop up somewhere.

@jtojnar
Copy link
Member

jtojnar commented Dec 10, 2019

Hmm, I can reproduce it in your repository; even with strictDeps = false;. So weird.

@jtojnar
Copy link
Member

jtojnar commented Dec 10, 2019

Oh, right you are doing makeWrapperArgs = [ "\${gappsWrapperArgs[@]}" ]; but bash needs the value quoted for the array items to be quoted.

@jtojnar
Copy link
Member

jtojnar commented Dec 10, 2019

makeWrapperArgs = [ "\"\${gappsWrapperArgs[@]}\"" ]; should work, through passing bash snippets through args/flags is not something I can recommend. It will probably break with #72074.

I suggest using

preFixup = ''
  makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
'';

cc @worldofpeace

@worldofpeace
Copy link
Contributor

I noticed this recently with python packages, because my example breaks in this fashion.
Will change the example to that @jtojnar.

worldofpeace added a commit to worldofpeace/nixpkgs that referenced this issue Dec 10, 2019
It now breaks down as mentioned in NixOS#75443
KoviRobi pushed a commit to KoviRobi/Pye-Menu that referenced this issue Dec 11, 2019
worldofpeace added a commit that referenced this issue Dec 11, 2019
…ting

wrapGAppsHook: don't add empty variables (see also #75443)
@KoviRobi
Copy link
Contributor Author

Thanks both! The suggested preFixup makeWrapperArgs works for me. Closing as there is both a fix to the docs and one for wrap-gapps-hook-shell which has been committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants