# Ubuntu 20.04 RStan installation issues

**URL:** <https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556>\
**Category:** RStan\
**Tags:** installation, rstan\
**Created:** [November 30, 2020, 12:38pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556 "2020-11-30T12:38:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sofia\_Ruiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sofia_ruiz/32/10032_2.png) [@Sofia\_Ruiz](https://discourse.mc-stan.org/u/Sofia_Ruiz)\
**Post date:** [November 30, 2020, 12:38pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/1 "2020-11-30T12:38:29Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [November 30, 2020, 6:58pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/2 "2020-11-30T18:58:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Sofia\_Ruiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sofia_ruiz/32/10032_2.png) [@Sofia\_Ruiz](https://discourse.mc-stan.org/u/Sofia_Ruiz)\
**Post date:** [November 30, 2020, 7:29pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/3 "2020-11-30T19:29:54Z")

</div>

Yes!  
I ran: " install.packages(“rstan”, repos = “[https://cloud.r-project.org/](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

```

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [November 30, 2020, 7:56pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/4 "2020-11-30T19:56:01Z")

</div>

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)

```

---

<div class="post-metadata">

**Author:** ![Sofia\_Ruiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sofia_ruiz/32/10032_2.png) [@Sofia\_Ruiz](https://discourse.mc-stan.org/u/Sofia_Ruiz)\
**Post date:** [November 30, 2020, 8:05pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/5 "2020-11-30T20:05:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [November 30, 2020, 9:36pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/6 "2020-11-30T21:36:30Z")

</div>

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:

> [@Sofia\_Ruiz](#):
>
> Try removing ‘/home/sofi/R/x86\_64-pc-linux-gnu-library/4.0/00LOCK-rstan’

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:

```no-highlight
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.

---

<div class="post-metadata">

**Author:** ![Sofia\_Ruiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sofia_ruiz/32/10032_2.png) [@Sofia\_Ruiz](https://discourse.mc-stan.org/u/Sofia_Ruiz)\
**Post date:** [December 1, 2020, 12:00am UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/7 "2020-12-01T00:00:34Z")

</div>

> [@jonah](#):
>
> ```no-highlight
> unlink("/home/sofi/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-rstan", recursive = TRUE)
> 
> ```

That worked!!! Thanks

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [December 1, 2020, 12:04am UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/8 "2020-12-01T00:04:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jenis\_patel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jenis_patel/32/10593_2.png) [@jenis\_patel](https://discourse.mc-stan.org/u/jenis_patel)\
**Post date:** [February 9, 2021, 3:09pm UTC](https://discourse.mc-stan.org/t/ubuntu-20-04-rstan-installation-issues/19556/9 "2021-02-09T15:09:45Z")

</div>

Thanks! had a similar problem.
