I am trying to measure the peak memory usage of an R script using /usr/bin/time. The following code works fine:
Rscript testMemoryUsage.R
as does:
time Rscript testMemoryUsage.R
However, the following doesn't work:
/usr/bin/time Rscript testMemoryUsage.R
The error is due to packages not being found:
"Error in library(tidyverse) : there is no package called ‘tidyverse’ Calls: suppressPackageStartupMessages -> withCallingHandlers -> library Execution halted Command exited with non-zero status 1"
I realize there is not much reproducible code but at a conceptually level, why does the shell built in time command work here but not the executable /usr/bin/time? How can I get /usr/bin/time to use the same R environment where the packages are installed? Thank you.