coolbutuseless / dplyr-cli

Manipulate CSV files on the command line using dplyr
MIT License
269 stars 20 forks source link

user should set TMPDIR env variable #12

Closed knbknb closed 4 years ago

knbknb commented 4 years ago

The README.md file should contain a note or paragraph that users should set TMPDIR env variable to a writable directory. I've set mine just now to TMPDIR=/tmp/dplyr to see what ends up in there.

Otherwise I get errors such as these cannot open compressed file '/file56d470cb5178.rds', probable reason 'Permission denied' for simple commands that mutate data.

Perhaps the script should also clean up that dir after finishing, but maybe you intended to do imlemnt this feature later anyway,

coolbutuseless commented 4 years ago

On my system (OSX with R and Rstudio), "TMPDIR" is always set. Could you post your output for sessionInfo() and Sys.getenv()? Also which shell are you using?

Maybe there are some systems where TMP or TEMP are used instead? Not sure. I'll be interested to see what your Sys.getenv() output is.

As to your second point, the script can't clean up the temp directory after finishing as a command does not know if it is the last command in the chain

knbknb commented 4 years ago

I am using bash on Linux.

Please see this, perhaps: Finding the correct tmp dir on multiple platforms where some experts tried to answer a related question.

"Linux, UNIX: supposed to be $TMPDIR but appears to be unset on multiple systems I tried"

My Sys.getenv() output contains this

SWT_GTK3                                                    0
TAR                                                         /bin/tar
TERM                                                        xterm-256color
THEME_SHOW_CLOCK_CHAR                                       false
TIME_STYLE                                                  long-iso
TOK                                                         mUehSBc...

R version 3.6.1 (2019-07-05) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.6 LTS

Matrix products: default BLAS: /usr/lib/openblas-base/libblas.so.3 LAPACK: /usr/lib/libopenblasp-r0.2.18.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=de_DE.UTF-8
[8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=de_DE.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.6.1 startup_0.14.1 magrittr_1.5 clisymbols_1.2.0 colorout_1.2-1 crayon_1.3.4 dang_0.0.11 prompt_1.0.0

coolbutuseless commented 4 years ago

What's the output of your R command tempdir()?

knbknb commented 4 years ago

tempdir()

"/tmp/RtmpfpveCS"

coolbutuseless commented 4 years ago

Thanks.

According to docs: The environment variables TMPDIR, TMP and TEMP are checked in turn and the first found which points to a writable directory is used: if none succeeds ‘/tmp’ is used.

I will mimic this behaviour.

coolbutuseless commented 4 years ago

Just posted a fix. Please re-open this issue if that did not fix the behaviour for you.