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

wireshark: export QT_PLUGIN_PATH in shellHook #42864

Closed
wants to merge 1 commit into from

Conversation

teto
Copy link
Member

@teto teto commented Jul 2, 2018

...else program fails with:
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Motivation for this change

I am fixing a bug in wireshark within a nix-shell and could not start the dev wireshark due to this error.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

...else program fails with:
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: wireshark

Partial log (click to expand)

shrinking /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/lib/wireshark/extcap/randpktdump
shrinking /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/lib/wireshark/extcap/sshdump
shrinking /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/lib/libwireshark.so.11.0.1
shrinking /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/lib/libwscodecs.so.0.0.0
gzipping man pages under /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/share/man/
strip is /nix/store/4qvrxzxa535y8304mk195x50b6p9607d-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/lib  /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1/bin
patching script interpreter paths in /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1
checking for references to /build in /nix/store/pflpji81p8gdm5x2pa7mzvgiq4scav7x-wireshark-qt-2.6.1...
postPatchMkspecs

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: wireshark

Partial log (click to expand)

shrinking /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1/bin/sharkd
shrinking /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1/bin/rawshark
shrinking /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1/bin/tshark
gzipping man pages under /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1/share/man/
strip is /nix/store/0pjsgkxz0rp5baycq5sp2s72lrr5q9sg-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1/lib  /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1/bin
patching script interpreter paths in /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1
checking for references to /build in /nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1...
postPatchMkspecs
/nix/store/b5yycqxv897bdhvzpycp2rchvzybc666-wireshark-qt-2.6.1

@orivej
Copy link
Contributor

orivej commented Jul 2, 2018

This issue is not specific to Wireshark, it is common to all Qt packages: you need ${qt5.qtbase}/bin (or the directory where it is installed, e.g. /run/current-system/sw/bin or ~/.nix-profile/bin) in your PATH for Qt to find its plugins. Does nix-shell -p qt5.qtbase wireshark work?

@matthewbauer
Copy link
Member

Ok this appears to be related to my issue: #42893

I didn't realize that qt apps needed qtbase installed. Can we provide a fallback path in these cases? IMO relying on propagatedUserEnvPkgs to do the right thing is harmful because not everyone will install your app through the traditional nix-env -i method.

@teto
Copy link
Member Author

teto commented Jul 3, 2018

@orivej what if qtbase/wireshark is not installed ? Installed wireshark works without any problem but I am doing some development on it, thus I would like build/run/wireshark to work without having to specify manually in nix-shell the correct paths.

@orivej
Copy link
Contributor

orivej commented Jul 3, 2018

@teto You only have to make sure that qtbase is in your PATH. If your nix-shell is not --pure, the PATH should be inherited from your shell, so you won't have to change it inside nix-shell. Make sure that nix-shell uses the same revision of Nixpkgs from which you have installed qtbase, otherwise plugins for that version of Qt may not be available or may fail to load. (You don't have to explicitly install qtbase as long as you install any application that depends on it, because it is a propagatedUserEnvPkgs package.) See also #42893 (comment).

@@ -91,6 +91,7 @@ in stdenv.mkDerivation {
shellHook = ''
# to be able to run the resulting binary
export WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1
export QT_PLUGIN_PATH=${qt5.qtbase.bin}/${qt5.qtbase.qtPluginPrefix}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to add this, it should probably be conditional on withQt.

Copy link
Member

@matthewbauer matthewbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a makeWrapper call adding QT_PLUGIN_PATH around $out/bin/wireshark makes more sense here.

@teto
Copy link
Member Author

teto commented Jul 14, 2018

@matthewbauer it is already wrapped. I am specifically targeting the developing phase when you are in your $ nix-shell -A wireshark and want to run the build/run/wiresahrk binary (i.e., no installPhase, no wrapper). Or do you mean it should be wrapped as a postBuild hook ? that would work too

@matthewbauer
Copy link
Member

Ok that seems like something we can do in the qt hook becuase it should apply to all qt based packages.

@teto
Copy link
Member Author

teto commented Jun 10, 2019

seems like more holistic solutions are coming up. closing

@teto teto closed this Jun 10, 2019
@teto teto deleted the wireshark branch September 5, 2021 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants