Instead of setting and then resetting the working directory it might be cleaner to provide the output of `tempdir` as a path in the retriever call. e.g.,

```
temppath = tempdir()
system(paste('retriever -q install csv', dataset, '--table-name', file.path(temppath, '{db}_{table}.csv'))
```