blob: c26d0ddc743595916ef4edacbdf647ac0c04bd62 [file] [log] [blame]
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Learn how to configure your environment to allow you to contribute to the arrow package
">
<title>Configuring a developer environment • Arrow R Package</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../../apple-touch-icon-60x60.png">
<script src="../../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="../../deps/bootstrap-5.2.2/bootstrap.min.css" rel="stylesheet">
<script src="../../deps/bootstrap-5.2.2/bootstrap.bundle.min.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../../pkgdown.js"></script><meta property="og:title" content="Configuring a developer environment">
<meta property="og:description" content="Learn how to configure your environment to allow you to contribute to the arrow package
">
<meta property="og:image" content="https://arrow.apache.org/img/arrow-logo_horizontal_black-txt_white-bg.png">
<meta property="og:image:alt" content="Apache Arrow logo, displaying the triple chevron image adjacent to the text">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@apachearrow">
<meta name="twitter:site" content="@apachearrow">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--><!-- Matomo --><script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
/* We explicitly disable cookie tracking to avoid privacy issues */
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '20']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script><!-- End Matomo Code -->
</head>
<body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar fixed-top navbar-dark navbar-expand-lg bg-black"><div class="container">
<a class="navbar-brand me-2" href="../../index.html">Arrow R Package</a>
<span class="version">
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">13.0.0</small>
</span>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a class="nav-link" href="../../articles/arrow.html">Get started</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../../reference/index.html">Reference</a>
</li>
<li class="active nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown-articles">Articles</a>
<div class="dropdown-menu" aria-labelledby="dropdown-articles">
<h6 class="dropdown-header" data-toc-skip>Using the package</h6>
<a class="dropdown-item" href="../../articles/read_write.html">Reading and writing data files</a>
<a class="dropdown-item" href="../../articles/data_wrangling.html">Data analysis with dplyr syntax</a>
<a class="dropdown-item" href="../../articles/dataset.html">Working with multi-file data sets</a>
<a class="dropdown-item" href="../../articles/python.html">Integrating Arrow, Python, and R</a>
<a class="dropdown-item" href="../../articles/fs.html">Using cloud storage (S3, GCS)</a>
<a class="dropdown-item" href="../../articles/flight.html">Connecting to a Flight server</a>
<div class="dropdown-divider"></div>
<h6 class="dropdown-header" data-toc-skip>Arrow concepts</h6>
<a class="dropdown-item" href="../../articles/data_objects.html">Data objects</a>
<a class="dropdown-item" href="../../articles/data_types.html">Data types</a>
<a class="dropdown-item" href="../../articles/metadata.html">Metadata</a>
<div class="dropdown-divider"></div>
<h6 class="dropdown-header" data-toc-skip>Installation</h6>
<a class="dropdown-item" href="../../articles/install.html">Installing on Linux</a>
<a class="dropdown-item" href="../../articles/install_nightly.html">Installing development versions</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="../../articles/index.html">More articles...</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="../../news/index.html">Changelog</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0" role="search">
<input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../../search.json" id="search-input" placeholder="Search for" autocomplete="off">
</form>
<ul class="navbar-nav">
<li class="nav-item">
<a class="external-link nav-link" href="https://github.com/apache/arrow/" aria-label="github">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
</div>
</nav><div class="container template-article">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<img src="" class="logo" alt=""><h1>Configuring a developer environment</h1>
<small class="dont-index">Source: <a href="https://github.com/apache/arrow/blob/main/r/vignettes/developers/setup.Rmd" class="external-link"><code>vignettes/developers/setup.Rmd</code></a></small>
<div class="d-none name"><code>setup.Rmd</code></div>
</div>
<p>Windows and macOS users who wish to contribute to the R package and don’t need to alter libarrow (Arrow’s C++ library) may be able to obtain a recent version of the library without building from source.</p>
<div class="section level4">
<h4 id="linux">Linux<a class="anchor" aria-label="anchor" href="#linux"></a>
</h4>
<p>On Linux, you can download a .zip file containing libarrow from the <a href="https://nightlies.apache.org/arrow/r/libarrow/bin/" class="external-link">nightly repository</a>.</p>
<p>The directory names correspond to the OpenSSL version the binaries built with: - “linux-openssl-1.0” (OpenSSL 1.0) - “linux-openssl-1.1” (OpenSSL 1.1) - “linux-openssl-3.0” (OpenSSL 3.0)</p>
<p>Version numbers in that repository correspond to dates.</p>
<p>You’ll need to create a <code>libarrow</code> directory inside the R package directory and unzip the zip file containing the compiled libarrow binary files into it.</p>
</div>
<div class="section level4">
<h4 id="macos">macOS<a class="anchor" aria-label="anchor" href="#macos"></a>
</h4>
<p>On macOS, you can install libarrow using <a href="https://brew.sh/" class="external-link">Homebrew</a>:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb1-1" title="1"><span class="co"># For the released version:</span></a>
<a class="sourceLine" id="cb1-2" title="2"><span class="ex">brew</span> install apache-arrow</a>
<a class="sourceLine" id="cb1-3" title="3"><span class="co"># Or for a development version, you can try:</span></a>
<a class="sourceLine" id="cb1-4" title="4"><span class="ex">brew</span> install apache-arrow --HEAD</a></code></pre></div>
</div>
<div class="section level4">
<h4 id="windows">Windows<a class="anchor" aria-label="anchor" href="#windows"></a>
</h4>
<p>On Windows, you can download a .zip file containing libarrow from the <a href="https://nightlies.apache.org/arrow/r/libarrow/bin/windows/" class="external-link">nightly repository</a>.</p>
<p>Version numbers in that repository correspond to dates.</p>
<p>You can set the <code>RWINLIB_LOCAL</code> environment variable to point to the zip file containing libarrow before installing the arrow R package.</p>
</div>
<div class="section level3">
<h3 id="r-and-c">R and C++<a class="anchor" aria-label="anchor" href="#r-and-c"></a>
</h3>
<p>If you need to alter both libarrow and the R package code, or if you can’t get a binary version of the latest libarrow elsewhere, you’ll need to build it from source. This section discusses how to set up a C++ libarrow build configured to work with the R package. For more general resources, see the <a href="https://arrow.apache.org/docs/developers/cpp/building.html" class="external-link">Arrow C++ developer guide</a>.</p>
<p>There are five major steps to the process.</p>
<div class="section level4">
<h4 id="step-1---install-dependencies">Step 1 - Install dependencies<a class="anchor" aria-label="anchor" href="#step-1---install-dependencies"></a>
</h4>
<p>When building libarrow, by default, system dependencies will be used if suitable versions are found. If system dependencies are not present, libarrow will build them during its own build process. The only dependencies that you need to install <em>outside</em> of the build process are <a href="https://cmake.org/" class="external-link">cmake</a> (for configuring the build) and <a href="https://www.openssl.org/" class="external-link">openssl</a> if you are building with S3 support.</p>
<p>For a faster build, you may choose to pre-install more C++ library dependencies (such as <a href="http://lz4.github.io/lz4/" class="external-link">lz4</a>, <a href="https://facebook.github.io/zstd/" class="external-link">zstd</a>, etc.) on the system so that they don’t need to be built from source in the libarrow build.</p>
<div class="section level5">
<h5 id="ubuntu">Ubuntu<a class="anchor" aria-label="anchor" href="#ubuntu"></a>
</h5>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb2-1" title="1"><span class="fu">sudo</span> apt install -y cmake libcurl4-openssl-dev libssl-dev</a></code></pre></div>
</div>
<div class="section level5">
<h5 id="macos-1">macOS<a class="anchor" aria-label="anchor" href="#macos-1"></a>
</h5>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb3-1" title="1"><span class="ex">brew</span> install cmake openssl</a></code></pre></div>
</div>
<div class="section level5">
<h5 id="windows-1">Windows<a class="anchor" aria-label="anchor" href="#windows-1"></a>
</h5>
<p>The package can be built on Windows using <a href="https://cran.r-project.org/bin/windows/Rtools/" class="external-link">RTools 4</a>. It can be built for mingw32 (i386), mingw64 (x64), or ucrt64 (UCRT x64). mingw64 is the recommended 64-bit installation.</p>
<p>Open the corresponding RTools Bash, for example “Rtools MinGW 64-bit” for mingw64.</p>
<p>Install CMake, ccache, and Ninja with:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb4-1" title="1"><span class="ex">pacman</span> --sync --refresh --noconfirm \</a>
<a class="sourceLine" id="cb4-2" title="2"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-<span class="dt">{ccache,cmake,ninja,openssl}</span></a>
<a class="sourceLine" id="cb4-3" title="3"><span class="bu">export</span> <span class="va">CMAKE_GENERATOR=</span>Ninja</a></code></pre></div>
<p>You will need to add R to your path. For a user-level installation, R will be at something like <code>~/Documents/R/R-4.1.2/bin</code>. For a global installation, R will be at something like <code>/c/Program\ Files/R/R-4.1.2/bin</code>. The R on your path needs to match the architecture you are compiling for, so if you are compiling on 32-bit specify <code>.../bin/i386</code> instead of <code>.../bin/x64</code>.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb5-1" title="1"><span class="bu">export</span> <span class="va">PATH=</span>~/Documents/R/R-4.1.2/bin/x64:<span class="va">$PATH</span></a></code></pre></div>
<p>You can install additional dependencies like so. Note that you are limited to the packages in <a href="https://github.com/r-windows/rtools-packages" class="external-link">the RTools repo</a>, which does not contain every dependency used by Arrow.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb6-1" title="1"><span class="ex">pacman</span> --sync --refresh --noconfirm \</a>
<a class="sourceLine" id="cb6-2" title="2"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-boost \</a>
<a class="sourceLine" id="cb6-3" title="3"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-brotli \</a>
<a class="sourceLine" id="cb6-4" title="4"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-lz4 \</a>
<a class="sourceLine" id="cb6-5" title="5"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-protobuf \</a>
<a class="sourceLine" id="cb6-6" title="6"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-snappy \</a>
<a class="sourceLine" id="cb6-7" title="7"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-thrift \</a>
<a class="sourceLine" id="cb6-8" title="8"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-zlib \</a>
<a class="sourceLine" id="cb6-9" title="9"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-zstd \</a>
<a class="sourceLine" id="cb6-10" title="10"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-aws-sdk-cpp \</a>
<a class="sourceLine" id="cb6-11" title="11"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-re2 \</a>
<a class="sourceLine" id="cb6-12" title="12"> <span class="va">${MINGW_PACKAGE_PREFIX}</span>-libutf8proc</a></code></pre></div>
</div>
</div>
<div class="section level4">
<h4 id="step-2---configure-the-libarrow-build">Step 2 - Configure the libarrow build<a class="anchor" aria-label="anchor" href="#step-2---configure-the-libarrow-build"></a>
</h4>
<p>We recommend that you configure libarrow to be built to a user-level directory rather than a system directory for your development work. This is so that the development version you are using doesn’t overwrite a released version of libarrow you may already have installed, and so that you are also able work with more than one version of libarrow (by using different <code>ARROW_HOME</code> directories for the different versions).</p>
<p>In the example below, libarrow is installed to a directory called <code>dist</code> that has the same parent directory as the arrow checkout. Your installation of the Arrow R package can point to any directory with any name, though we recommend <em>not</em> placing it inside of the arrow git checkout directory as unwanted changes could stop it working properly.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb7-1" title="1"><span class="bu">export</span> <span class="va">ARROW_HOME=$(</span><span class="bu">pwd</span><span class="va">)</span>/dist</a>
<a class="sourceLine" id="cb7-2" title="2"><span class="fu">mkdir</span> <span class="va">$ARROW_HOME</span></a></code></pre></div>
<p><em>Special instructions on Linux:</em> You will need to set <code>LD_LIBRARY_PATH</code> to the <code>lib</code> directory that is under where you set <code>$ARROW_HOME</code>, before launching R and using arrow. One way to do this is to add it to your profile (we use <code>~/.bash_profile</code> here, but you might need to put this in a different file depending on your setup, e.g. if you use a shell other than <code>bash</code>). On macOS you do not need to do this because the macOS shared library paths are hardcoded to their locations during build time.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb8-1" title="1"><span class="bu">export</span> <span class="va">LD_LIBRARY_PATH=$ARROW_HOME</span>/lib:<span class="va">$LD_LIBRARY_PATH</span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="bu">echo</span> <span class="st">"export LD_LIBRARY_PATH=</span><span class="va">$ARROW_HOME</span><span class="st">/lib:</span><span class="va">$LD_LIBRARY_PATH</span><span class="st">"</span> <span class="op">&gt;&gt;</span> ~/.bash_profile</a></code></pre></div>
<p><em>Special instructions on Windows:</em> You will need to add <code>$ARROW_HOME/bin</code> to your <code>PATH</code> if you are using dynamic libraries (which is recommended).</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb9-1" title="1"><span class="bu">export</span> <span class="va">PATH=$ARROW_HOME</span>/bin:<span class="va">$PATH</span></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="bu">echo</span> <span class="st">"export PATH=</span><span class="dt">\"</span><span class="va">$ARROW_HOME</span><span class="st">/bin:</span><span class="va">$PATH</span><span class="dt">\"</span><span class="st">"</span> <span class="op">&gt;&gt;</span> ~/.bash_profile</a></code></pre></div>
<p>Start by navigating in a terminal to the arrow repository. You will need to create a directory into which the C++ build will put its contents. We recommend that you make a <code>build</code> directory inside of the <code>cpp</code> directory of the Arrow git repository (it is git-ignored, so you won’t accidentally check it in). Next, change directories to be inside <code>cpp/build</code>:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb10-1" title="1"><span class="bu">pushd</span> arrow</a>
<a class="sourceLine" id="cb10-2" title="2"><span class="fu">mkdir</span> -p cpp/build</a>
<a class="sourceLine" id="cb10-3" title="3"><span class="bu">pushd</span> cpp/build</a></code></pre></div>
<p>You’ll first call <code>cmake</code> to configure the build and then <code>make install</code>. For the R package, you’ll need to enable several features in libarrow using <code>-D</code> flags:</p>
<div class="section level5">
<h5 id="section"></h5>
<div class="section level6">
<h6 id="linux-mac-os">Linux / Mac OS<a class="anchor" aria-label="anchor" href="#linux-mac-os"></a>
</h6>
<div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb11-1" title="1"><span class="fu">cmake</span> \</a>
<a class="sourceLine" id="cb11-2" title="2"> -DCMAKE_INSTALL_PREFIX=<span class="va">$ARROW_HOME</span> \</a>
<a class="sourceLine" id="cb11-3" title="3"> -DCMAKE_INSTALL_LIBDIR=lib \</a>
<a class="sourceLine" id="cb11-4" title="4"> -DARROW_COMPUTE=ON \</a>
<a class="sourceLine" id="cb11-5" title="5"> -DARROW_CSV=ON \</a>
<a class="sourceLine" id="cb11-6" title="6"> -DARROW_DATASET=ON \</a>
<a class="sourceLine" id="cb11-7" title="7"> -DARROW_EXTRA_ERROR_CONTEXT=ON \</a>
<a class="sourceLine" id="cb11-8" title="8"> -DARROW_FILESYSTEM=ON \</a>
<a class="sourceLine" id="cb11-9" title="9"> -DARROW_INSTALL_NAME_RPATH=OFF \</a>
<a class="sourceLine" id="cb11-10" title="10"> -DARROW_JEMALLOC=ON \</a>
<a class="sourceLine" id="cb11-11" title="11"> -DARROW_JSON=ON \</a>
<a class="sourceLine" id="cb11-12" title="12"> -DARROW_PARQUET=ON \</a>
<a class="sourceLine" id="cb11-13" title="13"> -DARROW_WITH_SNAPPY=ON \</a>
<a class="sourceLine" id="cb11-14" title="14"> -DARROW_WITH_ZLIB=ON \</a>
<a class="sourceLine" id="cb11-15" title="15"> ..</a></code></pre></div>
</div>
<div class="section level6">
<h6 id="windows-2">Windows<a class="anchor" aria-label="anchor" href="#windows-2"></a>
</h6>
<div class="sourceCode" id="cb12"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb12-1" title="1"><span class="fu">cmake</span> \</a>
<a class="sourceLine" id="cb12-2" title="2"> -DCMAKE_INSTALL_PREFIX=<span class="va">$ARROW_HOME</span> \</a>
<a class="sourceLine" id="cb12-3" title="3"> -DCMAKE_INSTALL_LIBDIR=lib \</a>
<a class="sourceLine" id="cb12-4" title="4"> -DARROW_COMPUTE=ON \</a>
<a class="sourceLine" id="cb12-5" title="5"> -DARROW_CSV=ON \</a>
<a class="sourceLine" id="cb12-6" title="6"> -DARROW_DATASET=ON \</a>
<a class="sourceLine" id="cb12-7" title="7"> -DARROW_EXTRA_ERROR_CONTEXT=ON \</a>
<a class="sourceLine" id="cb12-8" title="8"> -DARROW_FILESYSTEM=ON \</a>
<a class="sourceLine" id="cb12-9" title="9"> -DARROW_MIMALLOC=ON \</a>
<a class="sourceLine" id="cb12-10" title="10"> -DARROW_JSON=ON \</a>
<a class="sourceLine" id="cb12-11" title="11"> -DARROW_PARQUET=ON \</a>
<a class="sourceLine" id="cb12-12" title="12"> -DARROW_WITH_SNAPPY=OFF \</a>
<a class="sourceLine" id="cb12-13" title="13"> -DARROW_WITH_ZLIB=ON \</a>
<a class="sourceLine" id="cb12-14" title="14"> ..</a></code></pre></div>
</div>
</div>
<div class="section level5">
<h5 id="section-1"></h5>
<p><code>..</code> refers to the C++ source directory: you’re in <code>cpp/build</code> and the source is in <code>cpp</code>.</p>
<p><strong>For Windows</strong>: some options, including <code>-DARROW_JEMALLOC</code>, are not supported on Windows.</p>
</div>
<div class="section level5">
<h5 id="enabling-more-arrow-features">Enabling more Arrow features<a class="anchor" aria-label="anchor" href="#enabling-more-arrow-features"></a>
</h5>
<p>To enable optional features including: S3 support, an alternative memory allocator, and additional compression libraries, add some or all of these flags to your call to <code>cmake</code> (the trailing <code>\</code> makes them easier to paste into a bash shell on a new line):</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb13-1" title="1"> <span class="ex">-DARROW_GCS</span>=ON \</a>
<a class="sourceLine" id="cb13-2" title="2"> -DARROW_MIMALLOC=ON \</a>
<a class="sourceLine" id="cb13-3" title="3"> -DARROW_S3=ON \</a>
<a class="sourceLine" id="cb13-4" title="4"> -DARROW_WITH_BROTLI=ON \</a>
<a class="sourceLine" id="cb13-5" title="5"> -DARROW_WITH_BZ2=ON \</a>
<a class="sourceLine" id="cb13-6" title="6"> -DARROW_WITH_LZ4=ON \</a>
<a class="sourceLine" id="cb13-7" title="7"> -DARROW_WITH_SNAPPY=ON \</a>
<a class="sourceLine" id="cb13-8" title="8"> -DARROW_WITH_ZSTD=ON \</a></code></pre></div>
<p>Other flags that may be useful:</p>
<ul>
<li><p><code>-DBoost_SOURCE=BUNDLED</code> and <code>-DThrift_SOURCE=BUNDLED</code>, for example, or any other dependency <code>*_SOURCE</code>, if you have a system version of a C++ dependency that doesn’t work correctly with Arrow. This tells the build to compile its own version of the dependency from source.</p></li>
<li><p><code>-DCMAKE_BUILD_TYPE=debug</code> or <code>-DCMAKE_BUILD_TYPE=relwithdebinfo</code> can be useful for debugging. You probably don’t want to do this generally because a debug build is much slower at runtime than the default <code>release</code> build.</p></li>
<li><p><code>-DARROW_BUILD_STATIC=ON</code> and <code>-DARROW_BUILD_SHARED=OFF</code> if you want to use static libraries instead of dynamic libraries. With static libraries there isn’t a risk of the R package linking to the wrong library, but it does mean if you change the C++ code you have to recompile both the C++ libraries and the R package. Compilers typically will link to static libraries only if the dynamic ones are not present, which is why we need to set <code>-DARROW_BUILD_SHARED=OFF</code>. If you are switching after compiling and installing previously, you may need to remove the <code>.dll</code> or <code>.so</code> files from <code>$ARROW_HOME/dist/bin</code>.</p></li>
</ul>
<p><em>Note</em> <code>cmake</code> is particularly sensitive to whitespacing, if you see errors, check that you don’t have any errant whitespace.</p>
</div>
</div>
<div class="section level4">
<h4 id="step-3---building-libarrow">Step 3 - Building libarrow<a class="anchor" aria-label="anchor" href="#step-3---building-libarrow"></a>
</h4>
<p>You can add <code>-j#</code> at the end of the command here too to speed up compilation by running in parallel (where <code>#</code> is the number of cores you have available).</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb14-1" title="1"><span class="fu">cmake</span> --build . --target install -j8</a></code></pre></div>
</div>
<div class="section level4">
<h4 id="step-4---build-the-arrow-r-package">Step 4 - Build the Arrow R package<a class="anchor" aria-label="anchor" href="#step-4---build-the-arrow-r-package"></a>
</h4>
<p>Once you’ve built libarrow, you can install the R package and its dependencies, along with additional dev dependencies, from the git checkout:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb15-1" title="1"><span class="bu">popd</span> <span class="co"># To go back to the root directory of the project, from cpp/build</span></a>
<a class="sourceLine" id="cb15-2" title="2"><span class="bu">pushd</span> r</a>
<a class="sourceLine" id="cb15-3" title="3"><span class="ex">R</span> -e <span class="st">"install.packages('remotes'); remotes::install_deps(dependencies = TRUE)"</span></a>
<a class="sourceLine" id="cb15-4" title="4"><span class="ex">R</span> CMD INSTALL --no-multiarch .</a></code></pre></div>
<p>The <code>--no-multiarch</code> flag makes it only compile on the “main” architecture. This will compile for the architecture that the R in your path corresponds to. If you compile on one architecture and then switch to another, make sure to pass the <code>--preclean</code> flag so that the R package code is recompiled for the new architecture. Otherwise, you may see errors like <code>LoadLibrary failure: %1 is not a valid Win32 application</code>.</p>
<div class="section level5">
<h5 id="compilation-flags">Compilation flags<a class="anchor" aria-label="anchor" href="#compilation-flags"></a>
</h5>
<p>If you need to set any compilation flags while building the C++ extensions, you can use the <code>ARROW_R_CXXFLAGS</code> environment variable. For example, if you are using <code>perf</code> to profile the R extensions, you may need to set</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb16-1" title="1"><span class="bu">export</span> <span class="va">ARROW_R_CXXFLAGS=</span>-fno-omit-frame-pointer</a></code></pre></div>
</div>
<div class="section level5">
<h5 id="recompiling-the-c-code">Recompiling the C++ code<a class="anchor" aria-label="anchor" href="#recompiling-the-c-code"></a>
</h5>
<p>With the setup described here, you should not need to rebuild the Arrow library or even the C++ source in the R package as you iterate and work on the R package. The only time those should need to be rebuilt is if you have changed the C++ in the R package (and even then, <code>R CMD INSTALL .</code> should only need to recompile the files that have changed) <em>or</em> if the libarrow C++ has changed and there is a mismatch between libarrow and the R package. If you find yourself rebuilding either or both each time you install the package or run tests, something is probably wrong with your set up.</p>
<details><summary>For a full build: a <code>cmake</code> command with all of the R-relevant optional dependencies turned on. Development with other languages might require different flags as well. For example, to develop Python, you would need to also add <code>-DARROW_PYTHON=ON</code> (though all of the other flags used for Python are already included here).</summary><p>
</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb17-1" title="1"><span class="fu">cmake</span> \</a>
<a class="sourceLine" id="cb17-2" title="2"> -DCMAKE_INSTALL_PREFIX=<span class="va">$ARROW_HOME</span> \</a>
<a class="sourceLine" id="cb17-3" title="3"> -DCMAKE_INSTALL_LIBDIR=lib \</a>
<a class="sourceLine" id="cb17-4" title="4"> -DARROW_COMPUTE=ON \</a>
<a class="sourceLine" id="cb17-5" title="5"> -DARROW_CSV=ON \</a>
<a class="sourceLine" id="cb17-6" title="6"> -DARROW_DATASET=ON \</a>
<a class="sourceLine" id="cb17-7" title="7"> -DARROW_EXTRA_ERROR_CONTEXT=ON \</a>
<a class="sourceLine" id="cb17-8" title="8"> -DARROW_FILESYSTEM=ON \</a>
<a class="sourceLine" id="cb17-9" title="9"> -DARROW_GCS=ON \</a>
<a class="sourceLine" id="cb17-10" title="10"> -DARROW_INSTALL_NAME_RPATH=OFF \</a>
<a class="sourceLine" id="cb17-11" title="11"> -DARROW_JEMALLOC=ON \</a>
<a class="sourceLine" id="cb17-12" title="12"> -DARROW_JSON=ON \</a>
<a class="sourceLine" id="cb17-13" title="13"> -DARROW_MIMALLOC=ON \</a>
<a class="sourceLine" id="cb17-14" title="14"> -DARROW_PARQUET=ON \</a>
<a class="sourceLine" id="cb17-15" title="15"> -DARROW_S3=ON \</a>
<a class="sourceLine" id="cb17-16" title="16"> -DARROW_WITH_BROTLI=ON \</a>
<a class="sourceLine" id="cb17-17" title="17"> -DARROW_WITH_BZ2=ON \</a>
<a class="sourceLine" id="cb17-18" title="18"> -DARROW_WITH_LZ4=ON \</a>
<a class="sourceLine" id="cb17-19" title="19"> -DARROW_WITH_SNAPPY=ON \</a>
<a class="sourceLine" id="cb17-20" title="20"> -DARROW_WITH_ZLIB=ON \</a>
<a class="sourceLine" id="cb17-21" title="21"> -DARROW_WITH_ZSTD=ON \</a>
<a class="sourceLine" id="cb17-22" title="22"> ..</a></code></pre></div>
</details>
</div>
</div>
</div>
<div class="section level3">
<h3 id="installing-a-version-of-the-r-package-with-a-specific-git-reference">Installing a version of the R package with a specific git reference<a class="anchor" aria-label="anchor" href="#installing-a-version-of-the-r-package-with-a-specific-git-reference"></a>
</h3>
<p>If you need an arrow installation from a specific repository or git reference, on most platforms except Windows, you can run:</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu">remotes</span><span class="fu">::</span><span class="fu"><a href="https://remotes.r-lib.org/reference/install_github.html" class="external-link">install_github</a></span><span class="op">(</span><span class="st">"apache/arrow/r"</span>, build <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code></pre></div>
<p>The <code>build = FALSE</code> argument is important so that the installation can access the C++ source in the <code>cpp/</code> directory in <code>apache/arrow</code>.</p>
<p>As with other installation methods, setting the environment variables <code>LIBARROW_MINIMAL=false</code> and <code>ARROW_R_DEV=true</code> will provide a more full-featured version of Arrow and provide more verbose output, respectively.</p>
<p>For example, to install from the (fictional) branch <code>bugfix</code> from <code>apache/arrow</code> you could run:</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Sys.setenv.html" class="external-link">Sys.setenv</a></span><span class="op">(</span>LIBARROW_MINIMAL<span class="op">=</span><span class="st">"false"</span><span class="op">)</span></span>
<span><span class="fu">remotes</span><span class="fu">::</span><span class="fu"><a href="https://remotes.r-lib.org/reference/install_github.html" class="external-link">install_github</a></span><span class="op">(</span><span class="st">"apache/arrow/r@bugfix"</span>, build <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code></pre></div>
<p>Developers may wish to use this method of installing a specific commit separate from another Arrow development environment or system installation (e.g. we use this in <a href="https://github.com/ursacomputing/arrowbench" class="external-link">arrowbench</a> to install development versions of libarrow isolated from the system install). If you already have libarrow installed system-wide, you may need to set some additional variables in order to isolate this build from your system libraries:</p>
<ul>
<li><p>Setting the environment variable <code>FORCE_BUNDLED_BUILD</code> to <code>true</code> will skip the <code>pkg-config</code> search for libarrow and attempt to build from the same source at the repository+ref given.</p></li>
<li><p>You may also need to set the Makevars <code>CPPFLAGS</code> and <code>LDFLAGS</code> to <code>""</code> in order to prevent the installation process from attempting to link to already installed system versions of libarrow. One way to do this temporarily is wrapping your <code><a href="https://remotes.r-lib.org/reference/install_github.html" class="external-link">remotes::install_github()</a></code> call like so:</p></li>
</ul>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu">withr</span><span class="fu">::</span><span class="fu"><a href="https://withr.r-lib.org/reference/with_makevars.html" class="external-link">with_makevars</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>CPPFLAGS <span class="op">=</span> <span class="st">""</span>, LDFLAGS <span class="op">=</span> <span class="st">""</span><span class="op">)</span>, <span class="fu">remotes</span><span class="fu">::</span><span class="fu"><a href="https://remotes.r-lib.org/reference/install_github.html" class="external-link">install_github</a></span><span class="op">(</span><span class="va">...</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="summary-of-environment-variables">Summary of environment variables<a class="anchor" aria-label="anchor" href="#summary-of-environment-variables"></a>
</h2>
<ul>
<li>See the user-facing <a href="../install.html">article on installation</a> for a large number of environment variables that determine how the build works and what features get built.</li>
<li>
<code>TEST_OFFLINE_BUILD</code>: When set to <code>true</code>, the build script will not download prebuilt the C++ library binary. It will turn off any features that require a download, unless they’re available in <code>ARROW_THIRDPARTY_DEPENDENCY_DIR</code> or the <code>tools/thirdparty_download/</code> subfolder. <code><a href="../../reference/create_package_with_all_dependencies.html">create_package_with_all_dependencies()</a></code> creates that subfolder. Regardless of this flag’s value, <code>cmake</code> will be downloaded if it’s unavailable.</li>
</ul>
</div>
<div class="section level2">
<h2 id="troubleshooting">Troubleshooting<a class="anchor" aria-label="anchor" href="#troubleshooting"></a>
</h2>
<p>Note that after any change to libarrow, you must reinstall it and run <code>make clean</code> or <code>git clean -fdx .</code> to remove any cached object code in the <code>r/src/</code> directory before reinstalling the R package. This is only necessary if you make changes to libarrow source; you do not need to manually purge object files if you are only editing R or C++ code inside <code>r/</code>.</p>
<div class="section level3">
<h3 id="arrow-library---r-package-mismatches">Arrow library - R package mismatches<a class="anchor" aria-label="anchor" href="#arrow-library---r-package-mismatches"></a>
</h3>
<p>If libarrow and the R package have diverged, you will see errors like:</p>
<pre><code>Error: package or namespace load failed for ‘arrow' in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-r/00new/arrow/libs/arrow.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-r/00new/arrow/libs/arrow.so, 6): Symbol not found: __ZN5arrow2io16RandomAccessFile9ReadAsyncERKNS0_9IOContextExx
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-r/00new/arrow/libs/arrow.so
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-r/00new/arrow/libs/arrow.so
Error: loading failed
Execution halted
ERROR: loading failed</code></pre>
<p>To resolve this, try <a href="#step-3-building-arrow">rebuilding the Arrow library</a>.</p>
</div>
<div class="section level3">
<h3 id="multiple-versions-of-libarrow">Multiple versions of libarrow<a class="anchor" aria-label="anchor" href="#multiple-versions-of-libarrow"></a>
</h3>
<p>If you are installing from a user-level directory, and you already have a previous installation of libarrow in a system directory, you get you may get errors like the following when you install the R package:</p>
<pre><code>Error: package or namespace load failed for ‘arrow' in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-r/00new/arrow/libs/arrow.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-r/00new/arrow/libs/arrow.so, 6): Library not loaded: /usr/local/lib/libarrow.400.dylib
Referenced from: /usr/local/lib/libparquet.400.dylib
Reason: image not found</code></pre>
<p>If this happens, you need to make sure that you don’t let R link to your system library when building arrow. You can do this a number of different ways:</p>
<ul>
<li>Setting the <code>MAKEFLAGS</code> environment variable to <code>"LDFLAGS="</code> (see below for an example) this is the recommended way to accomplish this</li>
<li>Using {withr}’s <code>with_makevars(list(LDFLAGS = ""), ...)</code>
</li>
<li>adding <code>LDFLAGS=</code> to your <code>~/.R/Makevars</code> file (the least recommended way, though it is a common debugging approach suggested online)</li>
</ul>
<div class="sourceCode" id="cb23"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb23-1" title="1"><span class="va">MAKEFLAGS=</span><span class="st">"LDFLAGS="</span> <span class="ex">R</span> CMD INSTALL .</a></code></pre></div>
</div>
<div class="section level3">
<h3 id="rpath-issues">
<code>rpath</code> issues<a class="anchor" aria-label="anchor" href="#rpath-issues"></a>
</h3>
<p>If the package fails to install/load with an error like this:</p>
<pre><code> ** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'arrow' in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/you/R/00LOCK-r/00new/arrow/libs/arrow.so':
dlopen(/Users/you/R/00LOCK-r/00new/arrow/libs/arrow.so, 6): Library not loaded: @rpath/libarrow.14.dylib</code></pre>
<p>ensure that <code>-DARROW_INSTALL_NAME_RPATH=OFF</code> was passed (this is important on macOS to prevent problems at link time and is a no-op on other platforms). Alternatively, try setting the environment variable <code>R_LD_LIBRARY_PATH</code> to wherever Arrow C++ was put in <code>make install</code>, e.g. <code>export R_LD_LIBRARY_PATH=/usr/local/lib</code>, and retry installing the R package.</p>
<p>When installing from source, if the R and C++ library versions do not match, installation may fail. If you’ve previously installed the libraries and want to upgrade the R package, you’ll need to update the Arrow C++ library first.</p>
<p>For any other build/configuration challenges, see the <a href="https://arrow.apache.org/docs/developers/cpp/building.html" class="external-link">C++ developer guide</a>.</p>
</div>
<div class="section level3">
<h3 id="other-installation-issues">Other installation issues<a class="anchor" aria-label="anchor" href="#other-installation-issues"></a>
</h3>
<p>There are a number of scripts that are triggered when the arrow R package is installed. For package users who are not interacting with the underlying code, these should all just work without configuration and pull in the most complete pieces (e.g. official binaries that we host). However, knowing about these scripts can help package developers troubleshoot if things go wrong in them or things go wrong in an install. See <a href="./install_details.html">the article on R package installation</a> for more information.</p>
</div>
</div>
</main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
</nav></aside>
</div>
<footer><div class="pkgdown-footer-left">
<p></p>
<p><a href="https://arrow.apache.org/docs/r/versions.html">Older versions of these docs</a></p>
</div>
<div class="pkgdown-footer-right">
<p></p>
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.</p>
</div>
</footer>
</div>
</body>
</html>