Search code examples
ramazon-ec2packagerstudio-server

unable to install Rstudio packages in amazon EC2


I have installed amazon free trial linux t2.micro instance, and I installed RStudio, but when I try to install packages on R I get this error:

Warning in install.packages :
system call failed: Cannot allocate memory
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status

Even when I run a simple in R.

1+1

I get the same error:

system call failed: Cannot allocate memory


Solution

  • The problem is with the t2.micro instance. It has only 1GiB of Memory.

    Choosing a larger instance would be the appropriate solution here. If you want to stick with the Free Tier eligible instance (t2.micro), one possible solution would be is to add some swap space.

    Create a swap file for 1G (increase the value of count accordingly to increase the swap file size)

    dd if=/dev/zero of=/swapfile bs=1M count=1024
    mkswap /swapfile
    swapon /swapfile
    

    And, add this entry to /etc/fstab

    /swapfile swap swap defaults 0 0