Skip to content

wireshark: export QT_PLUGIN_PATH in shellHook - #42864

Closed
teto wants to merge 1 commit into
NixOS:masterfrom
teto:wireshark
Closed

teto wants to merge 1 commit into
NixOS:masterfrom
teto:wireshark

Conversation

@teto

@teto teto commented Jul 2, 2018

Copy link
Copy Markdown
Member

...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 GrahamcOfBorg added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jul 2, 2018
@GrahamcOfBorg

Copy link
Copy Markdown

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
Copy Markdown

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

orivej commented Jul 2, 2018 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

teto commented Jul 3, 2018

Copy link
Copy Markdown
Member Author

@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

orivej commented Jul 3, 2018 •

Copy link
Copy Markdown
Contributor

@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).

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
Copy Markdown
Member

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.

@matthewbauer matthewbauer left a comment

Copy link
Copy Markdown
Member

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

teto commented Jul 14, 2018

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
Member

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

@teto

teto commented Jun 10, 2019

Copy link
Copy Markdown
Member Author

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

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants