I have Ubuntu 16.04 and R 3.4.3. When I run

install.packages("geojson", dep=TRUE)

in R, I get the following error:

dependency ‘protolite’ is not available for package ‘geojson’

Therefore I run

install.packages("protolite", dep=TRUE)

to which I get:

Configuration failed because protobuf was not found. Try installing:
 * deb: libprotobuf-dev (Debian, Ubuntu, etc)
 * rpm: protobuf-devel (Fedora, EPEL)
 * csw: protobuf_dev (Solaris)
 * brew: protobuf (OSX)
If protobuf is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a protobuf.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

However, running protoc --version in terminal I get

libprotoc 2.6.1

So it seems I have the latest version installed. I also tried copying protobuf.pc in /usr/lib/pkconfig/ and setting PKG_CONFIG_PATH with

export PKG_CONFIG_PATH=/usr/lib/pkgconfig

with no success. I don't know how to check if pkg-config is in my PATH, nor how to follow the latter manual instructions. In particular, I don't know what directories I should write for INCLUDE_DIR=... and LIB_DIR=....

How should I proceed?

  • Did you install the libprotobuf-dev packages as suggested in the second error message? Or do you have and would like to use a different instance of that library? – David Foerster Mar 1 '18 at 11:50
  • yes, it tells me it is already the newest version – Nicu Righeriu Mar 1 '18 at 11:51
  • What's the output of pkg-config --modversion --cflags --libs protobuf? – David Foerster Mar 1 '18 at 11:54
  • { Ignoring incompatible output option "--cflags" Ignoring incompatible output option "--libs" 2.6.1 } – Nicu Righeriu Mar 1 '18 at 11:57
  • Huh? That's very odd. What's the output of which pkg-config, pkg-config --version and apt-cache policy pkg-config pkgconf? – David Foerster Mar 1 '18 at 12:01

I just found that my /usr/bin/pkg-config (version 0.29.1 bundled with Ubuntu 18.04) is ultra-buggy. It doesn't look into directories mentioned in PKG_CONFIG_PATH (custom directories were not seen in debug spew). I had to build newer version (0.29.2) from source. This solved my issue.

Hope it helps someone


You can install your R packages with the following actions

#1. add R 3.4.3 repository if not added before
cat <<EOF | sudo tee /etc/apt/sources.list.d/r-cran.list
deb https://cloud.r-project.org/bin/linux/ubuntu xenial/

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

#2. add repository for libjq-dev
sudo add-apt-repository -y ppa:opencpu/jq

#3. update package lists
sudo apt-get update

#4. install R and dependencies
sudo apt-get install r-base-dev r-base-core libjq-dev libcurl4-openssl-dev \
libssl-dev libprotobuf-dev libjq-dev libv8-3.14-dev protobuf-compiler

#5. launch R and install geojson package:
> install.packages("geojson", dep=TRUE)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.