Reputation: 7
I have build a singularity container based on r-base image and installing custom libraries like Seurat. Now I am trying to run my .Rmd script as follows:
singularity exec container.sif $(Rscript -e "rmarkdown::render('file.Rmd')")
But I get the error:
Error: 'LoadVizgen' is not an exported object from 'namespace:Seurat'
When I singularity shell container.sif
and I open R, I can load the Seurat library as well as the function LoadVizgen. My .libPaths() first path is "/usr/local/lib/R/site-library"
- in the container it contains many packages but in the host system, it contains none.
I understand that singularity uses my host libraries instead of those that are built within the container. I tried to run with a flag --no-home
and I tried to modify inside of my .Rmd file the .libPaths() but I still get the same error. Also, in both of those cases, when executing my .Rmd script
list.files("/usr/local/lib/R/site-library")
has no packages.
Would be happy to hear a solutions to this. Additionally, could you direct me or explain me why singularity containers use host libraries by default and how can one control specific path of libraries one wants to use? Thanks
Upvotes: 0
Views: 548
Reputation: 3772
The $(...)
statement is evaluated by bash and its output is what is sent to the singularity container. What you probably want is just:
singularity exec container.sif Rscript -e "rmarkdown::render('file.Rmd')"
# even better with cleanenv
singularity exec -e container.sif Rscript -e "rmarkdown::render('file.Rmd')"
Upvotes: 1