When working with very large sets of minc files (> ~800) in RMINC you may run into the following error:

Not enough available file descriptors to open <N> files, maybe try setting ulimit -Sn <some-larger-number>

R can only maintain a certain number of open files at a given time, if RMINC determines that you cannot open enough files to safely run your command it will issue the error above. In order to fix this problem:

  • Close the R session, and exit R studio if you are using it.
  • Open a terminal and check your current hard limit for open files with `ulimit -Hn`, here at MICe the number will likely be 4096
  • Set a new ulimit to the be the hardlimit with `ulimit -Sn 4096` or whatever your hardlimit turns out to be
  • Restart R/Rstudio from this terminal (the ulimit is local to a bash session, other terminals will be unaffected).