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

How to change .desktop entry on Linux to run R Studio with asdf R? #12

Open
emstruong opened this issue Jul 31, 2023 · 2 comments
Open

Comments

@emstruong
Copy link

Provide environment information

OS:
Linux boomer 5.19.0-46-generic #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 21 15:35:31 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

BASH VERSION:
5.1.16(1)-release

ASDF VERSION:
v0.12.0-816195d

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/boomer/.asdf
ASDF_DIR=/home/boomer/.asdf
ASDF_CONFIG_FILE=/home/boomer/.asdfrc

ASDF INSTALLED PLUGINS:
r                            https://github.com/asdf-community/asdf-r.git master dda1807

To Reproduce

  1. Install R Studio
  2. Install R 4.3.1 using asdf and set r 4.3.1 as global
  3. Try to open R studio through the desktop icon

Describe the Bug

R Studio doesn't start-up, presumably because it doesn't detect a version of R. Yet when R Studio is run in the terminal, it presumably detects that it should use the version of R based on asdf and runs

Expected Behaviour

R Studio should start using the version of R listed as global by asdf.

@emstruong
Copy link
Author

Related to #7, the Arch Wiki, and Posit, the solution I found was to copy the rstudio.desktop file from /usr/share/applications/rstudio.desktop to ~/.local/share/applications/rstudio.desktop.

Then I modified the exec line to be like so

Exec=env RSTUDIO_WHICH_R=/home/boomer/.asdf/shims/R /usr/lib/rstudio/rstudio %F

where boomer is the username.

Then update your .desktop files by running this in shell update-desktop-database ~/.local/share/applications -v.

I haven't tested whether this respects the R version in particular directories/projects, but it works well enough for me.

Presumably, it might be also helpful to mimic #7 by setting R_HOME_DIR=$HOME/.asdf/installs/R/<version>/lib/R as an environment variable, but I don't know if one can set multiple environment variables in the rstudio.desktop file.

In my testing, adjusting ~/.profile the way Posit recommends didn't help

@emstruong
Copy link
Author

Related to #7, the Arch Wiki, and Posit, the solution I found was to copy the rstudio.desktop file from /usr/share/applications/rstudio.desktop to ~/.local/share/applications/rstudio.desktop.

Then I modified the exec line to be like so

Exec=env RSTUDIO_WHICH_R=/home/boomer/.asdf/shims/R /usr/lib/rstudio/rstudio %F

where boomer is the username.

Then update your .desktop files by running this in shell update-desktop-database ~/.local/share/applications -v.

I haven't tested whether this respects the R version in particular directories/projects, but it works well enough for me.

Presumably, it might be also helpful to mimic #7 by setting R_HOME_DIR=$HOME/.asdf/installs/R/<version>/lib/R as an environment variable, but I don't know if one can set multiple environment variables in the rstudio.desktop file.

In my testing, adjusting ~/.profile the way Posit recommends didn't help

So far, I haven't been able to get R-Studio to run with the local version of R. If you start from the root of a R Studio Project directory, asdf loads the version of R listed in the .tool-versions file of that directory. Furthermore, it doesn't seem to appropriately change versions of R when projects are changed using that same instance of R Studio.

I imagine a fix would involve a change in R Studio's codebase in how it opens projects, but I'm not sure.

@emstruong emstruong reopened this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant