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

Specify .Rprofile and .Renviron when using singularity #855

Open
nickhir opened this issue Sep 12, 2024 · 5 comments
Open

Specify .Rprofile and .Renviron when using singularity #855

nickhir opened this issue Sep 12, 2024 · 5 comments
Labels

Comments

@nickhir
Copy link

nickhir commented Sep 12, 2024

Hi all,

I have been using the workflow described here to run RStudio on our HPC. Its been working brilliantly so far and makes my life so much easier, so thank you for that!

There is only one thing that I cant get to work: I would like to modify the .Rprofile and .Renviron that is being used by the singularity image, but I cant get it to work. I have tried to place the .Rprofile and .Renviron into the directory specfied by R_LIBS_USER, but the edits did not seem to make any impact (i.e. the settings I have specified in Rprofile did not show up when starting the singularity image.

Any help how to accomplish this would be much appreciated!

Cheers!

@eitsupi eitsupi transferred this issue from rocker-org/rocker Sep 12, 2024
@eddelbuettel
Copy link
Member

Have a look at the (epic, long) help page for help(Startup) about what R reads when and where. R_LIBS_USER is one of those things you can there with different Renviron or Rprofile files, it governs how the package library path (i.e. .libPaths()) is constructed. In general, the files you are after can be read from R's etc/ dir, the user's $HOME dir and the current processes startup directory.

@nickhir
Copy link
Author

nickhir commented Sep 12, 2024

Thank you very much for your answer! I added an .Rprofile to my $HOME directory (which is incidentally also the processes startup directory), but it did not change anything.

The output of the R.home() command is the following: "/usr/local/lib/R", however, I have noticed, that I can not change or add any files in the /usr/local/lib/R/etc directory because its a Read-only file system.

Furthermore, when I try to run usethis::edit_r_profile() I get the following error:

Error: [EISDIR] Failed to open '/rds/user/nickhir/hpc-work/software/R': illegal operation on a directory

Do you have any idea what else I could try?

@eddelbuettel
Copy link
Member

Yes, that can be a problem. These days I work single-user, mostly, and am root here but R is indeed happy to run off a read-only file system.

But let's go back to help(Startup). I think you can also have Renviron read from where an env var points to which may be a clean way to have it picked up. R_ENVIRON_USER seems to be one way:

$ echo "randomdoodle=bar78" > /tmp/r/renviron_demo.txt
$ R_ENVIRON_USER=/tmp/r/renviron_demo.txt Rscript -e 'Sys.getenv("randomdoodle")'
[1] "bar78"
$ 

@nickhir
Copy link
Author

nickhir commented Sep 12, 2024

Thank you very much for your support! I am afraid it is still not working.. I have added

export R_PROFILE_USER=/rds/user/nh608/hpc-work/software/R/.Rprofile # also tried without .Rprofile at the end
export R_ENVIRON_USER=/rds/user/nh608/hpc-work/software/R/.Renviron # also tried without .Renviron at the end

to the script shown here and it still does not work... Do I have to modify the singularity exec command in any way?

@nathanweeks
Copy link

@nickhir Were those environment variable settings added to the rsession.sh script (that also sets R_LIBS_USER)?

https://github.com/rocker-org/website/blob/e99414de7974ba0cb70306a9146594ca0f2e9200/use/singularity.md?plain=1#L96-L101

It seems setting R_PROFILE_USER and R_ENVIRON_USER there have the intended effect (with the rstudio_4.2.sif image listed in the job script). Note the path /rds/user/nh608/hpc-work/software/R/ has to exist in the container (in case it's not being mounted by default).

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

No branches or pull requests

4 participants