Solving the C Compiler Issue When Building R Packages with Conda on MacOS Mojave

If you’re a data scientist working with R packages on MacOS Mojave, you might have encountered a frustrating issue: the Conda build fails due to a C compiler problem. This issue can be a significant roadblock, but don’t worry, we’ve got you covered. In this blog post, we’ll walk you through the steps to resolve this problem and get your R packages up and running smoothly.

Solving the C Compiler Issue When Building R Packages with Conda on MacOS Mojave

If you’re a data scientist working with R packages on MacOS Mojave, you might have encountered a frustrating issue: the Conda build fails due to a C compiler problem. This issue can be a significant roadblock, but don’t worry, we’ve got you covered. In this blog post, we’ll walk you through the steps to resolve this problem and get your R packages up and running smoothly.

Understanding the Issue

Before we dive into the solution, let’s understand the problem. When you try to build an R package using Conda on MacOS Mojave, you might encounter an error message similar to this:

checking whether the C compiler works... no
configure: error: in `/private/var/folders/.../conda-build/...':
configure: error: C compiler cannot create executables

This error occurs because the C compiler that Conda uses is not compatible with MacOS Mojave. The issue is not with your code, but with the environment in which you’re trying to build your R package.

Step 1: Install Xcode Command Line Tools

The first step to resolve this issue is to install Xcode Command Line Tools. These tools include compilers that can help Conda build your R package successfully. You can install these tools by running the following command in your terminal:

xcode-select --install

Step 2: Install Homebrew

Next, you need to install Homebrew, a package manager for MacOS. Homebrew will help you install the necessary packages to resolve the C compiler issue. You can install Homebrew by running the following command in your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 3: Install GCC

Once you have Homebrew installed, you can use it to install GCC, a free software compiler collection. GCC includes a C compiler that is compatible with MacOS Mojave. You can install GCC by running the following command in your terminal:

brew install gcc

Step 4: Update Conda Build Configuration

The final step is to update your Conda build configuration to use the GCC compiler you just installed. You can do this by creating a .condarc file in your home directory with the following content:

c_compiler: gcc
cxx_compiler: g++

This configuration tells Conda to use the GCC compiler for C code and the G++ compiler for C++ code.

Conclusion

By following these steps, you should be able to resolve the C compiler issue when building R packages with Conda on MacOS Mojave. Remember, the key is to ensure that Conda is using a C compiler that is compatible with your operating system.

We hope this guide has been helpful. If you encounter any issues or have any questions, feel free to leave a comment below. Happy coding!


Keywords: Conda, R packages, MacOS Mojave, C compiler issue, data science, Xcode Command Line Tools, Homebrew, GCC, Conda build configuration

Meta Description: This blog post provides a step-by-step guide to resolving the C compiler issue when building R packages with Conda on MacOS Mojave. It is intended for data scientists and other technical professionals.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.