Unable to install.packages(): system call failed: Cannot allocate memory; installation of package had non-zero exit status
Asked Answered
C

3

23

I'm using R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" on Platform: x86_64-pc-linux-gnu (64-bit).

I have an issue installing new packages in R, using RStudio. When I call the install.packages() function, I get:

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

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

I have installed R via shell commands and it worked ok. I've also decreased the swappiness value to 10, but I'm not sure if it has anything to do with the problem.

Thanks in advance!

Comus answered 25/11, 2014 at 20:40 Comment(4)
What package are you trying to install? It does sound like a system problem rather than an R problem - how much RAM do you have free?Peasecod
I've tried installing "psych", "Hmisc" and "pastecs"; the same result for the three of them. I've tried: debug(install.packages) > install.packages("psych") > function (...) .rs.callAs(name, hook, original, ...) debugging in: install.packages("psych") MemTotal: 1909364 kB MemFree: 394692 kB Buffers: 3716 kB Cached: 354384 kB SwapCached: 0 kB Active: 1010724 kB Inactive: 320660 kBWayless
I got this error and resolved it by restarting my R sessionMalnourished
Monitor the RAM usage using "Gnome System Monitor". This desplay memory used/free ("free" actually means used for cache and buffers) and swap space used. I have 0 swap space used and about 3 GiB of RAM "free" and package installation fails with "Cannot allocate memory". Wut?? Could it be some other resource that is missing and the error message is wrong? RStudio has hoovered up 5 GiB so far. I just want to install ggmosaic! Restarting RStudio and relaunching install works, and RAM stays well within 2GiB used. There is a problem in RStudio somewhere.Schall
C
20

I figured out. I was all about the swap value.
There are several web pages that advice to decrease the default swap use in order to speed up Ubuntu. What I did to fix the problem.

In the terminal...

#Know the swap value    
cat /proc/sys/vm/swappiness
10
# Access the swap configuration
gksudo leafpad /etc/sysctl.conf

# Increase the swap usage to 30 (default is 60)
vm.swappiness=30

Then, I rebooted. And installed the packages happily without any problems.

Comus answered 25/11, 2014 at 21:46 Comment(9)
Hi Juan, I have my swap at 60 and still not working, any idea?Roll
Hi Jordan, I still have that problem sometimes, I'm not an expert, but I think is because I don't have much RAM. It happened when I was installing the gee package, so I closed all the apps, and tried again... It worked for me. Good luck!Wayless
Thanks a lot Juan, I managed to make it work by increasing the RAM in my instance too, so you are right, it looks like R doesn't get along very well with low RAM machines.Roll
OMG - this worked. I have no idea what I just did, but it worked. Gracias.Bodkin
If your swappiness is already 60, not enough memory is available to install the package. Restarting the server (sudo shutdown -r now) and installing the package first thing after it rebooted worked for me.Wimmer
I can confirm that @dter's suggestion worked for me. In short: rebooted and all good. Thank you.Cassandracassandre
Not sure if it was the change or the reboot, but it worked. Thanks!Huckaback
I have the exact problem. And my swap is already at 60, and I have 40 Gb of RAM in my box. When this happens, there is at least 16 Gb available. So, changing swap does not resolve the issue.Satterwhite
I have experienced this in R 3.6, but not R 3.5. It seems that when you have more than app. half of your memory in use, running system commands from within R with system() will result in 'Cannot allocate memory' errors. Even simple ones like system("ls"). Most install.packages() commands will envoke system() commands and thus produce the error. The work around of re-starting R (or re-booting) will work simply because memory is flushed. Maybe someone can comment on what has been changed from R 3.5 to R 3.6.Benson
M
3

just restart the r-session. that did the trick for me.

Maymaya answered 12/5, 2020 at 19:34 Comment(0)
T
1

I confirm that the problem was with RAM space. i closed some background applications and it installed smoothly without any need to reboot my system

Tank answered 21/1, 2019 at 6:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.