Ubuntu 20.04 RStan installation issues

Hi everyone!,
I tried to install the rstan package on a machine with Ubuntu 20.04.
I got the following error:
ERROR: dependency ‘rstan’ is not available for package ‘shinystan’

  • removing ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0/shinystan’

Could anyone help me, please?

Thanks!

Welcome to the Stan forums. Sorry you’re getting an error! This is a bit strange since it looks like it’s trying to install shinystan and not rstan and then complaining that rstan isn’t installed (because shinystan requires that). So I’m not entirely sure what’s going on. Can you share the exact code that you’re running that results in this error? And also is there more to the output or is this the only message that is displayed?

Yes!
I ran: " install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)"

An then I got the following :

Installing package into ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependency ‘shinystan’

trying URL 'https://cloud.r-project.org/src/contrib/shinystan_2.5.0.tar.gz'
Content type 'application/x-gzip' length 2400413 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

trying URL 'https://cloud.r-project.org/src/contrib/rstan_2.21.2.tar.gz'
Content type 'application/x-gzip' length 1152008 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

ERROR: failed to lock directory ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0’ for modifying
Try removing ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-rstan’
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status
ERROR: dependency ‘rstan’ is not available for package ‘shinystan’
* removing ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0/shinystan’
Warning in install.packages :
  installation of package ‘shinystan’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpHDhUXR/downloaded_packages’

The R and ubuntu versions are:
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          0.3                         
year           2020                        
month          10                          
day            10                          
svn rev        79318                       
language       R                           
version.string R version 4.0.3 (2020-10-10)
nickname       Bunny-Wunnies Freak Out

Hmm, it looks like it’s trying to install shinystan because rstan suggests it but shinystan requires rstan. So maybe we can just remove shinystan from the packages it’s trying to download. What about the following?

# find the dependencies and drop shinystan from the list
install.packages("remotes")
deps <- remotes::package_deps("rstan", dependencies = TRUE)
deps <- deps[!deps$package == "shinystan", ] 

# then this should install the dependencies
update(deps) 

# after that then try installing rstan without forcing it to install dependencies
install.packages("rstan", dependencies = FALSE)

I did what you suggested, but I still having problems.

when I ran update(deps), I got the following

** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path

  • DONE (processx)
  • installing source package ‘pillar’ …
    ** package ‘pillar’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    *** copying figures
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
  • DONE (pillar)
    ERROR: failed to lock directory ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0’ for modifying
    Try removing ‘/home/sofi/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-rstan’
    Error in i.p(…) :
    (converted from warning) installation of package ‘rstan’ had non-zero exit status

It looks like it is having trouble before it even gets to installing rstan. Towards the end of the output you posted it says this:

which is something I haven’t seen often but I think can happen if a previous attempt to install packages was aborted. Can you try removing that? You might be able to do that like this:

unlink("/home/sofi/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-rstan", recursive = TRUE)

but if that doesn’t work then maybe you can search for that file or folder on your computer and delete it manually.

1 Like

That worked!!! Thanks

Ok great, glad that’s working now! Thanks for letting us know.

Thanks! had a similar problem.