NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.11k stars 14.15k forks source link

rstudioWrapper not exporting environment variables in nix-shell #54872

Closed afrubin closed 3 years ago

afrubin commented 5 years ago

Issue description

rstudio won't open correctly when built using nix-shell as part of pkgs.rstudioWrapper.override on the master branch.

Starting rstudio returns the following error:

$ rstudio
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Aborted

However, when the same .nix file is passed to nix-build, the application starts as expected.

It appears that when built with nix-shell, the environment variables are not being set correctly:

$ cat $(which rstudio)
#! /nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash -e
export PATH=$PATH${PATH:+':'}'/nix/store/nj0aq4p4m55ci500x1flh8v2cc6snwh7-gnumake-4.2.1/bin'
exec -a "$0" "/nix/store/j5jvvi3sbpydji910xkb0xwyby078kwx-RStudio-1.1.463/bin/.rstudio-wrapped"  "${extraFlagsArray[@]}" "$@"

But they are being set correctly when built with nix-build:

$ cat result/bin/rstudio 
#! /nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash -e
export R_PROFILE_USER='/nix/store/slidksdja1p10im345m3mbkj8dsc54cb-RStudio-1.1.463-wrapper/fix_libs.R'
export QT_PLUGIN_PATH='/nix/store/kq10gqm6fx1r8k5402bkabc094n92flg-qtbase-5.12.0-bin/lib/qt-5.12/plugins'${QT_PLUGIN_PATH:+':'}$QT_PLUGIN_PATH
exec "/nix/store/j5jvvi3sbpydji910xkb0xwyby078kwx-RStudio-1.1.463/bin/rstudio"  "${extraFlagsArray[@]}" "$@"

According to the Nixpkgs documentation, using nix-shell with the rstudioWrapper should work correctly.

Using the stable version of Nixpkgs, both nix-shell and nix-build allow RStudio to start correctly.

Steps to reproduce

Use the example shell.nix from the Nixpkgs RStudio documentation with nix-shell on the master branch of Nixpkgs:

$ cat shell.nix 
{ pkgs ? import ../nixpkgs {}
}:

pkgs.rstudioWrapper.override {
  packages = with pkgs.rPackages; [ dplyr ggplot2 reshape2 ];
}

Technical details

knedlsepp commented 5 years ago

Could probably be fixed via: #54525

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.
jbedo commented 3 years ago

Resolved by #74381.