LoginSignup
4
4

More than 5 years have passed since last update.

OSXでRのパッケージtidyverseのインストールに詰まった

Last updated at Posted at 2018-08-24

AdventCalendar 13日目!
人手足りないけどだんないよ精神でいくよ!!!

概要

MacでR言語に入門する際に便利パッケージであるtidyverseのインストールに詰まったので対処法

環境

OS

ProductName:    Mac OS X
ProductVersion: 10.13.6

XCode

Xcode 9.3
Build version 9E145

R

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.6.0 (64-bit)

エラーコード

肝心のエラーコード

>install.packages("tidyverse")
Installing package into /usr/local/lib/R/3.5/site-library
(as lib is unspecified)
also installing the dependencies rvest, xml2

 URL 'https://cran.rstudio.com/src/contrib/rvest_0.3.2.tar.gz' を試しています 
Content type 'application/x-gzip' length 1597137 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

 URL 'https://cran.rstudio.com/src/contrib/xml2_1.2.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 251614 bytes (245 KB)
==================================================
downloaded 245 KB

 URL 'https://cran.rstudio.com/src/contrib/tidyverse_1.2.1.tar.gz' を試しています 
Content type 'application/x-gzip' length 61647 bytes (60 KB)
==================================================
downloaded 60 KB

* installing *source* package xml2 ...
**  パッケージ xml2 の解凍および MD5 サムの検証に成功しました 
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/libxml2
Using PKG_LIBS=-L/usr/lib -lxml2 -lz -lpthread -licucore -lm
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.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=...'
--------------------------------------------------------------------
ERROR: configuration failed for package xml2
* removing /usr/local/lib/R/3.5/site-library/xml2
Warning in install.packages :
  installation of package xml2 had non-zero exit status
ERROR: dependency xml2 is not available for package rvest
* removing /usr/local/lib/R/3.5/site-library/rvest
Warning in install.packages :
  installation of package rvest had non-zero exit status
ERROR: dependencies rvest, xml2 are not available for package tidyverse
* removing /usr/local/lib/R/3.5/site-library/tidyverse
Warning in install.packages :
  installation of package tidyverse had non-zero exit status

The downloaded source packages are in
    /private/var/folders/mf/h8zpddh14778rlv254chg2000000gs/T/RtmpO6u1wZ/downloaded_packages

対処1

ANTICONF ERRORで「libxml2が入ってないよ」的なエラーが出たのでとりあえずインストール

$ brew install lib2xml

再実行するが、同じエラーが出る
何故???

対処2

調べていると、どうもXCode絡みのよう

$ xcode-select --install

入った!!!

> library(tidyverse)
 Attaching packages ────────────── tidyverse 1.2.1 
 ggplot2 3.0.0      purrr   0.2.5
 tibble  1.4.2      dplyr   0.7.6
 tidyr   0.8.1      stringr 1.3.1
 readr   1.1.1      forcats 0.3.0
 Conflicts ──────────────── tidyverse_conflicts() 
 dplyr::filter() masks stats::filter()
 dplyr::lag()    masks stats::lag()

下のConflictsに関してはデフォルトっぽいのでそのままでOK

まとめ

そもそもXCodeのコマンドラインツールが入ってなかった
学習始めの環境構築で詰まるとモチベーションをグッと持っていかれる、、、

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4