Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source .bashrc in Rstudio

I have just installed some Perl modules locally in Ubuntu 18.04 LTS.

When calling them using the RStudio Server like this

system("perl -MBio::TreeIO -e 1")

I get the following error

Can't locate Bio/TreeIO.pm in @INC (you may need to install the Bio::TreeIO module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base)

When I source ~/.bashrc in the terminal everything's ok.

I tried creating a ~/.Rprofile containing:

system(". ~/.bashrc")

but no good.

like image 440
anajacintafernandes Avatar asked Oct 22 '25 05:10

anajacintafernandes


1 Answers

According to the documentation, accessed by running help(Startup) in the R shell, you should create a file .Renviron in your home directory which will be read when starting up a new R session. For example:

.Renviron

FOOBAR=/foo/bar/foo/bar

R shell

R
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...

> cat(Sys.getenv("FOOBAR"), "\n")
/foo/bar/foo/bar 

So just create your .Renviron file with the PERL5LIB variable set to your local perl package installation directory.

like image 132
xxfelixxx Avatar answered Oct 23 '25 17:10

xxfelixxx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!