cran4linux/bspm

bspm keeps asking me for root access to update/install packages

Closed this issue · 15 comments

Here are the details accordingly to your suggestion on Twitter.

Installation

I have followed installation instructions here:

https://github.com/Enchufa2/bspm#ubuntu

sudo add-apt-repository ppa:marutter/rrutter4.0   # R v4.0 and higher
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+  # R packages
sudo apt-get update
sudo apt-get install r-cran-bspm python3-{dbus,gi,apt}

When I try to install or update packages, I have to give root access:

image

Linux version

❯ lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20.3
Release:	20.3
Codename:	una

R sessionInfo

> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20.3

Matrix products: default
BLAS/LAPACK: /opt/intel/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C               LC_TIME=en_CA.UTF-8       
 [4] LC_COLLATE=en_CA.UTF-8     LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_CA.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_4.2.0 tools_4.2.0   

apt repos

❯ apt-cache policy r-base-core
r-base-core:
  Installed: (none)
  Candidate: 4.1.3-1.2004.0
  Version table:
     4.1.3-1.2004.0 500
        500 http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
     3.6.3-2 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages

Did you also set

  options(bspm.sudo = TRUE)

in your startup files as suggested in the docs or in my tweet to you ?

Not yet. Let me try.

This is now really a discussion of how apt works and how to maintain a Debian-based installation. This is the wrong place for that, and I believe I now suggested twice that you should post on r-sig-debian. Please do.

If you execute the command sudo apt install gdal-bin libgdal-dev ... (add more as needed) apt will tell you why it thinks it sees a conflict.

None of this has anything to do with bspm and it is not exactly fair to spam Inaki's repo with these questions.

Just a bit of complementary information.

I have tried to use options(bspm.sudo = TRUE). This is the error message I am now getting.

> options(bspm.sudo = TRUE)
> install.packages("lme4")
Error in install.packages : cannot connect to the system package manager

The installation works when options(bspm.sudo = FALSE), but still requires sudo access.

That is strange (and possibly related to your choice of distro) as I am using this rather heavily myself on both Docker and local Ubuntu machines (mostly under Ubuntu 20.04 aka "focal"). It must have something to do with the handoff to systemd in the back. Maybe @Enchufa2 can figure out how / why.

In the meantime can you please provide us with version information on the python components implied here, either via dpkg -l or via pip or whatever is used. You may have to dig in the package docs for bspm to see which ones these are?

The issue is in the packaging of r-cran-bspm from the ppa:c2d4u.team/c2d4u4.0+ repo, because the system service is not packaged (cc @marutter). I.e., the following files:

/usr/share/dbus-1/system-services/org.r_project.linux1.service
/etc/dbus-1/system.d/org.r_project.linux1.conf

are missing. If you force a system installation from CRAN, i.e.,

$ sudo Rscript --vanilla -e 'install.packages("bspm", repos="https://cran.r-project.org")'

then it should work.

Whoa. Good catch. Is that something bspm could re-check on package load and warn about?

Something like this?

> library(bspm)
Warning message:
D-Bus service not found!

- If you are in a container environment, please consider adding the
  following to your configuration to silence this warning:

  options(bspm.sudo = TRUE)

- If you are in a desktop/server environment, please remove any 'bspm'
  installation from the user library and force a new system
  installation as follows:

  $ sudo Rscript --vanilla -e 'install.packages("bspm", repos="https://cran.r-project.org")'

Yes, I would. Maybe with override option bspm.silent (or bspm.no_startup_check or ...) to suppress it. But it is a key feature and you dug out that how it was installed matters.

(Also, it bspm is already present we need to force source reinstallation so maybe add type = "source" to the above.)

Yes, I would. Maybe with override option bspm.silent (or bspm.no_startup_check or ...) to suppress it. But it is a key feature and you dug out that how it was installed matters.

No need for an additional option because there are basically three possible cases:

  1. In passwordless sudo environments (i.e., containers, toolboxes...), options(bspm.sudo = TRUE) must be set, and this silences the warning.
  2. In regular desktop/server environments in which the service is properly installed, no warning is raised, obviously.
  3. If a user is in a desktop/server environment and still wants to call sudo and provide the password every time, then again options(bspm.sudo = TRUE) must be set, which again silences the warning.

(Also, it bspm is already present we need to force source reinstallation so maybe add type = "source" to the above.)

Not needed, because every package installation from CRAN with vanilla R on Linux is from source. Or am I missing something?

  1. If a user is in a desktop/server environment and still wants to call sudo and provide the password every time, then again options(bspm.sudo = TRUE) must be set, which again silences the warning.

Well, I correct myself: no, this is just for passwordless sudo. But then, maybe it's better to show the warning in such a case unconditionally? Because calling sudo when a password is required will only work for interactive sessions. Anyway, an additional option to silence this won't hurt.

Worked fine on my side:

❯ sudo /usr/bin/Rscript --vanilla -e 'install.packages("bspm", repos="https://cran.r-project.org")' 
Installing package into ‘/usr/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/bspm_0.3.9.tar.gz'
Content type 'application/x-gzip' length 14351 bytes (14 KB)
==================================================
downloaded 14 KB

* installing *source* package ‘bspm’ ...
** package ‘bspm’ successfully unpacked and MD5 sums checked
** using staged installation
* installing /usr/share/dbus-1/system-services/org.r_project.linux1.service
* installing /etc/dbus-1/system.d/org.r_project.linux1.conf
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (bspm)

I am now able to use bspm in my workflow.

@PMassicotte Nice, thanks! Let's keep this open until the warning discussed above is implemented.

Thanks to you for digging into it!

@eddelbuettel And I think it's best to show the warning when calling bspm::enable(), and not on load.