Error to install sf package under R

I configured Jupyterhub with datascience-notebook (Selecting an Image — Docker Stacks documentation). When I try to install sf package for R from Terminal by inputing install.packages(“sf”), I got error:

>install.packages(“sf”) 
        ................................
	installing to /opt/conda/lib/R/library/00LOCK-s2/00new/s2/libs
	** R
	** data
	*** moving datasets to lazyload DB
	** inst
	** byte-compile and prepare package for lazy loading
	** help
	*** installing help indices
	*** copying figures
	** building package indices
	** testing if installed package can be loaded from temporary location
	** checking absolute paths in shared objects and dynamic libraries
	** testing if installed package can be loaded from final location
	** testing if installed package keeps a record of temporary installation ath
	* DONE (s2)
	ERROR: dependency ‘units’ is not available for package ‘sf’
	* removing ‘/opt/conda/lib/R/library/sf’
	
	The downloaded source packages are in
	        ‘/tmp/RtmpPcFudJ/downloaded_packages’
	Updating HTML index of packages in '.Library'
	Making 'packages.html' ... done
	Warning messages:
	1: In install.packages("sf") :
	  installation of package ‘units’ had non-zero exit status
	2: In install.packages("sf") :
	  installation of package ‘sf’ had non-zero exit status
>

I try to install package units, but it requires package udunits…

The Jupyterhub is installed from helm3: JupyterHub helm charts | JupyterHub’s Helm chart repository in Microk8s (1.29/stable). Microk8s is deployed on Ubuntu 22.04 LTS.

Any idea?

It is unliklely to be related to jupyterhub, but rather the R installation in your image. It looks like installation of units failed, you could try by starting with installing units directly:

install.packages("units")

and see if you get a more informative error. I get:

configure: error:
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.

which suggests there is a missing dependency that you need to install first.

Thanks for the reply.
When I do install.packages(“units”), I get exactly what you have. It looks like I need to install libudunits-dev, but I don’t know how to install.
I try to do: install.packages(“libudunits”) and install.packages(“libudunits-dev”). Both don’t work. I check all installed packages by: installed.packages()[,], I don’t find out packages of libudunits or libudunuts-dev.
My Jupyterhub version is Ubuntu 22.04. Please see the output:

jovyan@jupyter-xiaowang:~$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

libudunits2 is not a Julia but a Debian package.
You have to install it using sudo apt install libudunits2-dev.

However, since you probably don’t have root rights inside the container, the Docker image has to install the dependency.

Thanks. You are right. I have no root privilege under Jupyterhub.

jovyan@jupyter-xiaowang:~$ sudo ls
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

So how can I install ?

I install Jupyterhub by:

microk8s helm3 repo add jupyterhub  https://jupyterhub.github.io/helm-chart/