DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Install R Packages with devtools on Ubuntu

A complete Ubuntu guide to installing devtools and local R packages, with exact commands, dependency choices, permission fixes, compilation troubleshooting, and source-versus-binary guidance.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable Ubuntu workflow has three layers: install R and the operating system’s build tools, install devtools from CRAN, then run devtools::install() from your package directory. If installation fails with a missing header or library, the fix is usually an Ubuntu development package—not another R command.

This guide covers local packages, dependency choices, permissions, source-versus-binary trade-offs, and the common curl, SSL, XML, GDAL, GEOS, and compiler errors that stop builds.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand what devtools is installing

An R package can contain pure R code, compiled C/C++ or Fortran code, or links to external libraries. devtools coordinates the R-side work, but it cannot supply a compiler or Ubuntu system headers. A failed build therefore has two possible dependency layers:

  • R dependencies: packages named in Depends, Imports, LinkingTo, or Suggests.
  • Operating-system dependencies: compilers, headers, and libraries installed through Ubuntu’s package manager.

The distinction matters. Installing an R package named for a library does not provide the corresponding Ubuntu header, and installing an Ubuntu library does not install its R binding.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Check the R version before changing anything

In a terminal, run:

R --version

This confirms which R executable your shell will start. It also gives you a precise value to record when reporting a build failure or reproducing an installation on another Ubuntu machine. Inside R, you can inspect the active version with R.version.string.

Install the baseline Ubuntu toolchain

On a machine where you have administrator access, update the package index and install R, R’s development files, and the standard compilation toolchain:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install r-base r-base-dev build-essential

Package names can vary between Ubuntu releases. If apt reports that a package is unavailable, use the package name provided by your release’s repositories rather than mixing packages from another Ubuntu version.

Do not install every conceivable -dev package pre-emptively. Start with this baseline, attempt the R installation, and add only the system libraries identified by the first meaningful compiler error or by the package’s own installation documentation.

Install devtools from CRAN

The documented CRAN installation is performed in an R session:

  1. Start R by entering R in a terminal, or open your normal R IDE.
  2. Install the package with install.packages("devtools").
  3. Load it with library(devtools).
install.packages("devtools")
library(devtools)

During installation, R may ask you to select a CRAN mirror. Choose a mirror that is reachable from your network. If the session cannot reach the configured mirror, fix the network, proxy, certificate, or repository setting before diagnosing compilation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm that the package loaded and note its version:

packageVersion("devtools")

If this command fails immediately after installation, read the complete error, including the first warning about a dependency. A later “non-zero exit status” line is often only a summary of an earlier, more useful error.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Install a package from its local directory

Change to the directory that contains the package source. A valid package normally has a DESCRIPTION file and an R directory; packages with compiled code may also contain src.

Install from the current directory

devtools::install()

When called without a path, install() treats the current working directory as the package. In a shell, you can start R in that directory, or set the directory inside R with setwd("/path/to/package").

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install by giving an explicit path

devtools::install("/path/to/package")

An absolute path avoids ambiguity when several copies of a project exist. On Linux, use forward slashes and verify the path with file.exists("/path/to/package/DESCRIPTION") if R says it cannot find a package.

What happens during installation

devtools::install() delegates the package build and installation to R CMD INSTALL. It also resolves package dependencies using the current devtools and pak workflow. The output normally shows the package being staged, compiled if necessary, checked, and copied into an R library.

A successful install does not prove that every optional feature works. Packages often place examples, vignettes, tests, or integrations in Suggests. Decide whether those optional components are needed before choosing the dependency scope.

Choose the dependency scope deliberately

The dependencies argument controls which entries in the package metadata are installed. These settings are materially different:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting Installs Use it when Risk or trade-off
NA Hard dependencies: Depends, Imports, and LinkingTo You want the normal installation with required runtime and compilation dependencies. Optional examples, tests, and vignettes in Suggests are not installed.
TRUE The hard dependencies plus optional Suggests You need the package’s tests, vignettes, examples, or optional integrations. More packages take longer to install and create a larger dependency surface.
FALSE No dependency installation The environment was deliberately pre-provisioned and its dependency set is controlled elsewhere. The package can be unusable or fail during installation when required dependencies are absent.

The default hard-dependency behavior is the safe choice for most personal installations:

devtools::install(dependencies = NA)

Use TRUE when you know you need optional components:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
devtools::install(dependencies = TRUE)

Reserve FALSE for an image, container, or managed workstation where another process has already installed and verified every required R package:

devtools::install(dependencies = FALSE)

Handle R-library permissions

R may try to write to a system library owned by root. A warning about an unwritable library is a permissions problem, not evidence that the package source is broken.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use an administrator-managed library

If this is a shared machine and administrators own the system R installation, ask an administrator to run the installation or to provide a writable shared library. Avoid routinely running an entire interactive R session as root; that can create root-owned files in your home directory and complicate later updates.

Use a user library

For a personal installation, create a library under your home directory and install there:

dir.create(path.expand("~/R/library"), recursive = TRUE, showWarnings = FALSE)
.libPaths(c(path.expand("~/R/library"), .libPaths()))
devtools::install("/path/to/package")

The first path in .libPaths() is then your user-owned destination. If you need a one-off, non-default library without changing the session globally, use withr::with_libpaths():

withr::with_libpaths(new = path.expand("~/R/library"),
  devtools::install("/path/to/package")
)

Make sure the directory exists and is writable before retrying. Installing into a user library does not remove the need for Ubuntu headers when the package contains compiled code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decide between source and binary installation

On Ubuntu, a local package installed with devtools::install() is normally built from source. Source builds are flexible and transparent, but they require a compatible compiler and every required system header. A binary repository can avoid much of that compilation work.

Consideration Source installation Linux binary repository
Build speed Can be slow for packages with substantial compiled code. Usually faster because compilation has already been performed.
System requirements Requires local compilers and matching development libraries. Portable binaries can bundle system dependencies on supported Linux environments.
Version flexibility Can build a local checkout or a version not available as a binary. Limited to versions and platforms published by the repository.
Reproducibility Depends on your compiler, Ubuntu release, headers, and R toolchain. Improves consistency when the repository supports your Ubuntu and R combination.
Repository control Uses the CRAN mirror and other repositories configured in R. Uses the binary provider’s repository URL and availability policy.

Posit Package Manager can provide portable Linux binaries that bundle system dependencies for supported environments. Configure the repository in R using the URL supplied by your administrator or by the service documentation:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
options(repos = c(CRAN = "<repository-url>"))

Replace the value with your approved repository address; do not use the literal angle-bracket text. Set this option before installing dependencies, and confirm that the repository offers binaries for your Ubuntu release and R version. A binary repository is not a universal fallback: unsupported combinations may still require source compilation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fix missing compiler and library errors

Read compiler output from the first missing file or library. The final line saying that installation had a non-zero exit status is usually a consequence, not the root cause. Install the matching Ubuntu development package, then rerun the same R command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compiler, linker, or make errors

Messages mentioning gcc, g++, gfortran, make, or a missing compiler indicate that the build toolchain is incomplete:

sudo apt update
sudo apt install build-essential r-base-dev

Some packages need a language-specific compiler in addition to the standard toolchain. Follow the package’s documented Ubuntu prerequisites and the exact compiler name reported by the error.

curl or SSL headers

Errors naming files such as curl/curl.h, OpenSSL headers, or SSL libraries mean the R package’s native code cannot find the relevant development files. On Ubuntu, the commonly corresponding packages are:

sudo apt install libcurl4-openssl-dev libssl-dev

The correct package can differ by Ubuntu release or by the SSL implementation expected by the package. If apt cannot locate one, search the repositories for the header name and use the package available for your release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

XML headers

For errors referring to libxml or libxml2 headers, install the XML development package:

sudo apt install libxml2-dev

Retry only after the command completes successfully. Then rerun devtools::install(); do not delete the package source directory unless the error specifically indicates a damaged checkout.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

GDAL and GEOS libraries

Spatial packages commonly fail when the GDAL or GEOS headers and libraries are absent. The usual Ubuntu development packages are:

sudo apt install libgdal-dev libgeos-dev

Spatial software can also require additional libraries not named in the first error. Install the first missing dependency, retry, and continue through the next explicit missing item rather than guessing a large collection of packages.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the error to map the package

  1. Copy the first “fatal error” or “cannot find” line, including the header or library name.
  2. Determine whether it refers to a compiler, a header, or a linker library.
  3. Install the Ubuntu -dev package that provides that file for your release.
  4. Run the same devtools::install() command again.
  5. If the next attempt exposes a different missing item, repeat the mapping process.

Ubuntu system dependencies are separate from R dependencies. Installing an R package with a similar name will not satisfy a missing C header.

Install development versions and remote packages carefully

The devtools project documents pak::pak("r-lib/devtools") for installing its development version:

pak::pak("r-lib/devtools")

Use a development version only when you have a reason—such as testing a fix or reproducing an issue—and record the repository reference and R version used. Development code can change before a stable release.

For another GitHub-hosted package, use a repository you trust and follow that project’s installation instructions. Check its stated system requirements before starting a build; a remote source does not remove the need for Ubuntu compilers or headers.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make installations reproducible

Reproducibility is mainly a matter of recording choices that otherwise remain implicit:

  • Record R --version and the Ubuntu release.
  • Record the CRAN mirror or binary repository configured in options("repos").
  • Record whether dependencies were installed with NA, TRUE, or FALSE.
  • Keep the exact package source revision or archive used for a local or remote install.
  • For compiled packages, record the Ubuntu -dev libraries added to make the build succeed.
  • Use a user library or an administrator-managed library consistently rather than alternating between them.

These details explain why two machines with the same R command can produce different results: they may use different repositories, Ubuntu releases, compilers, or system headers.

End-to-end installation recipes

Standard administrator-managed source install

  1. In a terminal, run sudo apt update.
  2. Install r-base, r-base-dev, and build-essential.
  3. Start R and run install.packages("devtools").
  4. Load the package with library(devtools).
  5. Change to the package directory or pass its absolute path.
  6. Run devtools::install(dependencies = NA).
  7. If compilation stops, install the Ubuntu package corresponding to the first missing header or library and retry.

User-owned library on a workstation

  1. Install the Ubuntu prerequisites with administrator assistance.
  2. In R, create ~/R/library and prepend it to .libPaths().
  3. Install devtools and the local package into that user library.
  4. Use withr::with_libpaths() for one-off installs when you do not want to alter the session globally.

Binary-oriented team environment

  1. Obtain the approved Posit Package Manager repository address.
  2. Set options(repos = c(CRAN = "<repository-url>")) with the real address.
  3. Verify that binaries exist for the team’s Ubuntu and R versions.
  4. Install devtools and package dependencies from that repository.
  5. Use source installation only for packages or versions the binary repository does not provide.

Quick troubleshooting checklist

  • R starts, but the package is not found: check R --version, the working directory, and the path to DESCRIPTION.
  • The CRAN download fails: test network access and the configured mirror before changing compiler settings.
  • A library is not writable: switch to a user library or have an administrator install into the shared library.
  • A header is missing: identify the first header in the compiler output and install its Ubuntu development package.
  • Builds are too slow or repeatedly fail on system libraries: use a compatible Linux binary repository when one is available.
  • Dependencies are missing at runtime: reinstall with dependencies = NA or TRUE, depending on whether optional components are required.
  • You used dependencies = FALSE unintentionally: rerun the installation with the appropriate dependency scope rather than manually guessing R packages.

Final verification

After installation, start a fresh R session, load the package, and inspect the installed version:

library(yourPackageName)
packageVersion("yourPackageName")

Replace yourPackageName with the package’s actual name. A clean load in a fresh session catches missing runtime dependencies and library-path mistakes that can remain hidden in the session used for installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.