trinker / pacman

A package management tools for R
311 stars 37 forks source link

Specify directory for `p_load` #84

Open jdossgollin opened 7 years ago

jdossgollin commented 7 years ago

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

Dasonk commented 7 years ago

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?

jdossgollin commented 7 years ago

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

Dasonk commented 7 years ago

@trinker This should be an easy enough function but what do you think about the naming for it?

trinker commented 7 years ago

p_set_library?? maybe

jdossgollin commented 7 years ago

I like it

Dasonk commented 7 years ago

p_set_libpath seems like it would be more truthful on what it does.

trinker commented 7 years ago

Works for me.

On Apr 30, 2017 2:29 PM, "Dason Kurkiewicz" notifications@github.com 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 .

IdoBar commented 6 years ago

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().

trinker commented 6 years ago

@IdoBar no. Could you do a pull request?

IdoBar commented 6 years ago

@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

trinker commented 6 years ago

@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?

IdoBar commented 6 years ago

@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).

joh4nd commented 1 year ago

Hi, was the set path feature ever added? And can someone direct me, if it exists, to the documentation of the default path/library?

SinaedaA commented 1 year ago

@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)

joh4nd commented 1 year ago

@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.

SinaedaA commented 1 year ago

@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

NathanLazarus commented 1 year ago

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!