pacman
pacman copied to clipboard
Specify directory for `p_load`
Feature request:
Whether working locally with multiple versions of R or on a cluster where the package directory is in a non-standard location, it would be very helpful to be able to specify a directory to which packages should be saved. This would probably have to include not only p_load
but p_load_gh
, p_update
, etc.
I'm not sure whether it makes more sense to have this as a function argument or an option that is set; will leave that to devs
As the whole point of pacman is to make the user's life easier this is a great suggestion.
The way I see the function being implemented is just making a call to .libPaths()
@jdossgollin Do you have any suggestions for a name that would make sense for this function?
Yeah .libPaths()
should do it (I think? -- that's what I've been doing so far..)
Hate to make such a big decision but something like p_pkgdir
or p_setdir
or even p_set_pkgdir
. There is already a p_path
which would be worth bearing in mind
@trinker This should be an easy enough function but what do you think about the naming for it?
p_set_library
?? maybe
I like it
p_set_libpath
seems like it would be more truthful on what it does.
Works for me.
On Apr 30, 2017 2:29 PM, "Dason Kurkiewicz" [email protected] wrote:
p_set_libpath seems like it would be more truthful on what it does.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/trinker/pacman/issues/84#issuecomment-298248531, or mute the thread https://github.com/notifications/unsubscribe-auth/ABrnzs2CGXBPzalvKPFbm_A84LMpXchSks5r1NLxgaJpZM4MLmt5 .
Any updates regarding this option/functionality?
At the moment, when using p_load(package, update=TRUE)
and compiling packages from source, p_load()
uses the default R library (.Library
) rather than the location defined by .libPaths()
.
@IdoBar no. Could you do a pull request?
@trinker It seems like the issue was with packages that are installed in R's home folder as part of the base installation and it then asks whether you want to install in user folder and does uses the path at libPaths()
, so all good.
I did a pull request though on p_load()
to make sure that when using the update=TRUE
flag, only the specified packages will be updated, rather than all the old ones (from old.packages()
), I think it makes more sense.
Thanks, Ido
@IdoBar Does this address the original ask of this issue...to be able to specify the location of where packages are saved?
@Dasonk upon rereading this thread would it seems we were approaching this by globally setting the lib rary location. Should this still be taken as an argument to the functions originally suggested by the OP?
@trinker For the purpose of specifying packages location I would suggest the same solution suggested earlier by @Dasonk , i.e. using .libPaths()
.
I think that the issue can be closed, but this solution should be mentioned in the documentation.
My pull request was actually addressing another issue - the behaviour of the update=TRUE
flag to behave as expected (at least by me).
Hi, was the set path feature ever added? And can someone direct me, if it exists, to the documentation of the default path/library?
@joh4nd I don't think they ever added it, which is a shame, because .libPaths() can contain several paths, and when using it inside an Rscript, p_load
will return this annoying message for each package you're trying to load.
[1] "loading packages"
Installing package into ‘/home/sinaeda/Rpackages’
(as ‘lib’ is unspecified)
I feel like adding a lib
option inside p_load would really help...
What is your question about default path/library? If you use .libPaths()
inside R it will return a vector containing the directories where R is going to look for, and install packages. If you want to specify another directory, which is not contained in .libPaths(), you can create a file called .Renviron in your home directory, containing the following line:
R_LIBS=~/Rpackages
Note that Rpackages must be an existing directory, so you can just create it in bash.
Then restart R and your Rpackages directory should be added in .libPaths()
(NOTE this is for unix systems, I don't know about Windows)
@SinaedaA cheers, I guess I was trying to ask how one can tell (without inferring from its behavior) what path or directory pacman is programmed to use.
@joh4nd There is a p_path()
function inside pacman, which basically returns the same as .libPaths()
... But knowing which one it is using when calling p_load
for example, I don't know.
By default though (in my experience at least), R will use the first one appearing in .libPaths()
:) This was also the case with p_load
Yes, I think this would improve usability a lot if one could specify which directory in .libPaths() to use, or just specify an install directory!