0

Hello I'm getting an issue whereby after loading some objects I cannot do any type of system call. I notice this because even my pdf rendering would not work.

For example

 > sessionInfo()
Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) : 
cannot popen '/usr/bin/which 'uname' 2>/dev/null', probable reason 'Cannot allocate memory'

When I try knitr it gives me a similar error. However I still have plenty of memory left, for example I can load a huge 1GB dataframe and it will be running fine.

my rstudio session is as follow:

R version 3.5.0 (2018-04-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.5.0  htmltools_0.3.6 tools_3.5.0     yaml_2.2.0      Rcpp_1.0.1      rmarkdown_1.12  knitr_1.22      xfun_0.6        digest_0.6.18   evaluate_0.13 

Any suggestions?


> Sys.which("uname")
Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) :
    cannot popen '/usr/bin/which 'uname' 2>/dev/null', probable reason 'Cannot allocate memory'  
> traceback()  
4: system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) 
3: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning")) 
2: suppressWarnings(system(paste(which, shQuote(names[i])), intern = TRUE,         ignore.stderr = TRUE)) 
1: Sys.which("uname")
r2evans
  • 141,215
  • 6
  • 77
  • 149
Ahdee
  • 4,679
  • 4
  • 34
  • 58
  • 1
    So you try `sessionInfo()`, it fails for memory, and then you can *immediately* load a *new* 1GB dataset with no issue? (BTW: ubuntu 14.04 is past its [HWE support](https://wiki.ubuntu.com/Releases) by 3 years, perhaps there are underlying system issues going on here.) – r2evans Aug 08 '19 at 18:24
  • Hi @r2evans pretty much. sessionInfo() fails but I can do pretty much anything in rstudio like loading big objects. When I check my memory there is a least 40GB or so left. – Ahdee Aug 08 '19 at 19:43
  • I might be missing something, but that sounds like an OS thing, where R is giving a confusing error message (mis-classified failure). This is not the only question that has similarly-obscure behavior (https://stackoverflow.com/questions/12322959), but I haven't found a clear narrowing of the problem to be able to suggest a way-ahead. (Perhaps this is related: https://github.com/HenrikBengtsson/Wishlist-for-R/issues/36) – r2evans Aug 08 '19 at 20:11
  • (How are you able to paste session info when `sessionInfo()` fails with allocation errors?) Try `sessionInfo()`, and when it fails, run `traceback()` and compare it with Henrik's trace in the GH issue in my previous comment. Is it similar? – r2evans Aug 08 '19 at 20:13
  • Does `Sys.which("uname")` work by itself? – r2evans Aug 08 '19 at 20:14
  • @r2evans so I ```> Sys.which("uname")Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) : cannot popen '/usr/bin/which 'uname' 2>/dev/null', probable reason 'Cannot allocate memory' > traceback() 4: system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) 3: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning")) 2: suppressWarnings(system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE)) 1: Sys.which("uname")``` Sorry can't get multiline code to format correctly here – Ahdee Aug 08 '19 at 20:43
  • Multi-line goes in the question. – r2evans Aug 08 '19 at 20:52
  • So this seems to be ***exactly*** Henrik's issue: apparently R cannot find the command-line tool `which`. When I do `system("which")`, I get its `Usage: /usr/bin/which ...`, I'm guessing you will not. Because R's `Sys.which` is really an internal command, my guess is that R does not recognize that `which` (that is installed/available/executable on every linux system I've ever maintained) either is not found or something else bad about it ... and complains about memory instead. You might be outta luck on this one. – r2evans Aug 08 '19 at 20:55
  • 1
    @r2evans the strange thing is that it will run just fine for bit when I restart the rstudio. I think somehow one of the package I'm loading is messing with this. I don't know which one though. thanks. At least it sort of makes sense now. – Ahdee Aug 08 '19 at 21:07
  • I have a hard time imagining a linux system not having `which` available, so your thought that a package might be messing with holds some weight ... but I also have a hard time imagining something messing with one of R's `.Internal(...)` functions. Try uninstall/reinstall R, perhaps that nuclear option will work. (Make sure you know what ubuntu packages you will need to reinstall ...) – r2evans Aug 08 '19 at 21:13
  • Ok in case someone else needs this. It is indeed due to memory. Its a weird error whereby any system call requires upwards of 7GB. I tested this hypothesis out by spinning up an AWS with a lot more memory and it works fine now. Its really weird since the error does not reflect this. Also if there is not enough memory and you try to knit the markdown will return with an error code 127. – Ahdee Aug 08 '19 at 22:57
  • While I don't doubt that you found 7GB or more resolves some things ... I have a *really* hard time imagining any base utility in any unix-like OS requiring even a quarter of that. (On my linux systems, `which` is a shell script that does nothing to stretch the system. And `/bin/sh` should never strain a system.) – r2evans Aug 08 '19 at 23:05

0 Answers0