Tormod Landet

Articles tagged with R

  1. Installing R in WSL

    Short note for posteriority: the documentation for R tells you to install the key for the Ubuntu 18.04 R repository via the following command:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
    

    Using apt-key in this way does not work on Ubuntu 18.04 on Windows 10 (in WSL, Windows Subsystem for Linux) due to use of an unsupported IPC mechanism for communicating with dirmngr (at least with Windows 10 version 1709). The command gives the following error:

    Executing: /tmp/apt-key-gpghome.Sf0LlrpiEu/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
    gpg: connecting dirmngr at '/tmp/apt-key-gpghome.Sf0LlrpiEu/S.dirmngr' failed: IPC connect call failed
    gpg: keyserver receive failed: No dirmngr
    

    Instead run the following command to add the key:

    curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x51716619E084DAB9" | sudo apt-key add
    

    How did I get the number 0x51716619E084DAB9? Add the repository and run apt update:

    sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
    sudo apt update
    

    It will complain:

    Err:2 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ InRelease
      The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9
    

    Solution:

    The full set of commands to install R from the r-project.org repositories:

    curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x51716619E084DAB9" | sudo apt-key add
    sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
    sudo apt-get update
    sudo apt-get install r-base
    

    I'm not really much of an R user, but I needed it this one time and I prefer using WSL when I have to use Windows.