Ignore Sites Option For libPaths

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Ignore Sites Option For libPaths

Dario Strbenac-2
Good day,

Could .libPaths gain an option to ignore all values other than the user-specified new parameter? Currently, it takes the union of new and .Library and .Library.site and there is no way to turn it off. For quick and convenient troubleshooting that doesn't involve requiring the editing of configuration files, it would be nice to be able to run .libPaths(.libPaths()[1], ignoreSiteFiles = TRUE) to limit to only one folder of R packages.

> .libPaths()
[1] "/dskh/nobackup/biostat/Rpackages/v4" "/usr/users/course/splus/library/R"
[3] "/usr/lib/R/site-library"             "/usr/lib/R/library"
> .libPaths(.libPaths()[1]) # No option to ignore system-wide folders.
> .libPaths() # Paths are same as before.
[1] "/dskh/nobackup/biostat/Rpackages/v4" "/usr/users/course/splus/library/R"
[3] "/usr/lib/R/site-library"             "/usr/lib/R/library"

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Gabriel Becker-2
Hi Dario,

My switchr package is designed specifically to do what you're describing,
and does support excluding site libraries. So clearly I agree it would be
useful, but also, it does go against the "concept" of site libraries
somewhat.

I agree it would be a useful addition with the default to including them,
personally. And the patch would be pretty easy to put together. I can put
together a patch and add it to bugzilla as a wishlist item and we'll see
what thoughts are (unless I hear an emphatic no here, in which case I won't
bother, or unless you'd like to take a crack at it yourself).

~G

On Tue, Dec 8, 2020 at 3:00 PM Dario Strbenac <[hidden email]>
wrote:

> Good day,
>
> Could .libPaths gain an option to ignore all values other than the
> user-specified new parameter? Currently, it takes the union of new and
> .Library and .Library.site and there is no way to turn it off. For quick
> and convenient troubleshooting that doesn't involve requiring the editing
> of configuration files, it would be nice to be able to run
> .libPaths(.libPaths()[1], ignoreSiteFiles = TRUE) to limit to only one
> folder of R packages.
>
> > .libPaths()
> [1] "/dskh/nobackup/biostat/Rpackages/v4"
> "/usr/users/course/splus/library/R"
> [3] "/usr/lib/R/site-library"             "/usr/lib/R/library"
> > .libPaths(.libPaths()[1]) # No option to ignore system-wide folders.
> > .libPaths() # Paths are same as before.
> [1] "/dskh/nobackup/biostat/Rpackages/v4"
> "/usr/users/course/splus/library/R"
> [3] "/usr/lib/R/site-library"             "/usr/lib/R/library"
>
> --------------------------------------
> Dario Strbenac
> University of Sydney
> Camperdown NSW 2050
> Australia
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Dirk Eddelbuettel
In reply to this post by Dario Strbenac-2

On 8 December 2020 at 23:00, Dario Strbenac wrote:
| Could .libPaths gain an option to ignore all values other than the user-specified new parameter? Currently, it takes the union of new and .Library and .Library.site and there is no way to turn it off.

Are you use? It is constructed from looking at environment variables you could set.

  edd@rob:~$ R_LIBS="/tmp" R_LIBS_SITE="/var" Rscript -e 'print(.libPaths())'
  [1] "/tmp"               "/var"               "/usr/lib/R/library"
  edd@rob:~$

Dirk

--
https://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Gabriel Becker-2
Of course you can, but the ability to do something via R code and the
ability to do them by wrapping the invocation of R are not similar terms of
convenience, IMO.

I say that as someone who routinely does both type of thing.

~G

On Tue, Dec 8, 2020 at 4:07 PM Dirk Eddelbuettel <[hidden email]> wrote:

>
> On 8 December 2020 at 23:00, Dario Strbenac wrote:
> | Could .libPaths gain an option to ignore all values other than the
> user-specified new parameter? Currently, it takes the union of new and
> .Library and .Library.site and there is no way to turn it off.
>
> Are you use? It is constructed from looking at environment variables you
> could set.
>
>   edd@rob:~$ R_LIBS="/tmp" R_LIBS_SITE="/var" Rscript -e
> 'print(.libPaths())'
>   [1] "/tmp"               "/var"               "/usr/lib/R/library"
>   edd@rob:~$
>
> Dirk
>
> --
> https://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Dario Strbenac-2
In reply to this post by Dirk Eddelbuettel
Good day,

That seems like a straightforward and reasonable thing to do, but:

~$ R_LIBS="/tmp" R_LIBS_SITE="/var" Rscript -e 'print(.libPaths())'
[1] "/dora/nobackup/biostat/Rpackages/v4" "/dora/users/course/splus/library/R"
[3] "/usr/lib/R/site-library"             "/usr/lib/R/library"

/tmp and /var exist of course.

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Dirk Eddelbuettel

On 9 December 2020 at 02:00, Dario Strbenac wrote:
| That seems like a straightforward and reasonable thing to do, but:
|
| ~$ R_LIBS="/tmp" R_LIBS_SITE="/var" Rscript -e 'print(.libPaths())'
| [1] "/dora/nobackup/biostat/Rpackages/v4" "/dora/users/course/splus/library/R"
| [3] "/usr/lib/R/site-library"             "/usr/lib/R/library"

Hm. Maybe you have code in RHOME/etc/* or in HOME to set some of these?

The (very detailed) description of what happens when is in help(Startup)
which is a great resource but as dense as they get. My example came from my
Ubuntu 20.04 box where I set nothing apart from not using a ~/R/ path.

Also try "R -q -e 'print(.libPaths())'" with these switches to narrow it down:

  --no-environ          Don't read the site and user environment files
  --no-site-file        Don't read the site-wide Rprofile                
  --no-init-file        Don't read the user R profile

| /tmp and /var exist of course.

Right, I didn't stress that but the choice made it clear.  I still think you
should be able to tune this with just base R.

Cheers, Dirk

--
https://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Martin Maechler
In reply to this post by Gabriel Becker-2
>>>>> Gabriel Becker
>>>>>     on Tue, 8 Dec 2020 17:09:57 -0800 writes:

    > Of course you can, but the ability to do something via R
    > code and the ability to do them by wrapping the invocation
    > of R are not similar terms of convenience, IMO.

    > I say that as someone who routinely does both type of
    > thing.

    > ~G

I agree with Gabe here.
Also, R allows the user to remove their own home directory, it
should also allow to get a .libPaths() which contains nothing compulsory
but R's own .Library {as only that can contain 'base' !}

Martin


    > On Tue, Dec 8, 2020 at 4:07 PM Dirk Eddelbuettel
    > <[hidden email]> wrote:

    >>
    >> On 8 December 2020 at 23:00, Dario Strbenac wrote: |
    >> Could .libPaths gain an option to ignore all values other
    >> than the user-specified new parameter? Currently, it
    >> takes the union of new and .Library and .Library.site and
    >> there is no way to turn it off.
    >>
    >> Are you use? It is constructed from looking at
    >> environment variables you could set.
    >>
    >> edd@rob:~$ R_LIBS="/tmp" R_LIBS_SITE="/var" Rscript -e
    >> 'print(.libPaths())' [1] "/tmp" "/var"
    >> "/usr/lib/R/library" edd@rob:~$
    >>
    >> Dirk

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Dirk Eddelbuettel

On 9 December 2020 at 09:49, Martin Maechler wrote:
| Also, R allows the user to remove their own home directory, it
| should also allow to get a .libPaths() which contains nothing compulsory
| but R's own .Library {as only that can contain 'base' !}

That would be a very nice-to-have feature! But right now, .libPaths() does
now allow this per my reading of the help page:

     ‘.libPaths’ is used for getting or setting the library trees that
     R knows about (and hence uses when looking for packages).  If
     called with argument ‘new’, the library search path is set to the
     existing directories in ‘unique(c(new, .Library.site, .Library))’
     and this is returned.  If given no argument, a character vector
     with the currently active library trees is returned.

Hence I was trying to help OP approximate the behaviour via the command-line
but count me in as in terms of supporting this in R itself if you want to
make such a change.

Dirk

--
https://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Ignore Sites Option For libPaths

Gabriel Becker-2
Hi all,

I had intended to do this sooner, but I have filed a wishlist entry, with
patch, for supporting this on bugzilla.

Best,
~G

On Wed, Dec 9, 2020 at 10:48 AM Dirk Eddelbuettel <[hidden email]> wrote:

>
> On 9 December 2020 at 09:49, Martin Maechler wrote:
> | Also, R allows the user to remove their own home directory, it
> | should also allow to get a .libPaths() which contains nothing compulsory
> | but R's own .Library {as only that can contain 'base' !}
>
> That would be a very nice-to-have feature! But right now, .libPaths() does
> now allow this per my reading of the help page:
>
>      ‘.libPaths’ is used for getting or setting the library trees that
>      R knows about (and hence uses when looking for packages).  If
>      called with argument ‘new’, the library search path is set to the
>      existing directories in ‘unique(c(new, .Library.site, .Library))’
>      and this is returned.  If given no argument, a character vector
>      with the currently active library trees is returned.
>
> Hence I was trying to help OP approximate the behaviour via the
> command-line
> but count me in as in terms of supporting this in R itself if you want to
> make such a change.
>
> Dirk
>
> --
> https://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel