ERROR: CONDA_BUILD_SYSROOT or SDKROOT has to be set for cross-compiling when running the terminal

1.1k Views Asked by At

so my issue is that when I run the terminal on a MacBook Pro M1, after installing the miniforge3 & Conda, whenever I run the terminal the first thing that appears is this:

Last login: Thu Jul  1 15:36:59 on ttys000
ERROR: CONDA_BUILD_SYSROOT or SDKROOT has to be set for cross-compiling
activate_clang:67: read-only file system: /meson_cross_file.txt
activate_clang:68: read-only file system: /meson_cross_file.txt
activate_clang:69: read-only file system: /meson_cross_file.txt
activate_clang:70: read-only file system: /meson_cross_file.txt
activate_clang:71: read-only file system: /meson_cross_file.txt

Googling the error shows nothing that is able to help me or I simply get the "no results" message. How do I set it right?

1

There are 1 best solutions below

0
On

I run into the same scenario with miniforge, Apple Silicon (M1) when performing the following:

# Exclude external factors in my environment
$> mv ~/.zshrc ~/.not_zshrc
<close/open terminal>

$> curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
$> sh Miniforge3-MacOSX-arm64.sh -b -p ~/miniforge3
$> export PATH=~/miniforge3/bin:$PATH
$> conda init zsh
<close/open terminal>

$> conda create -n test clang_osx-64
$> conda activate test

The activate script involved is being built as thus:

if [ "@CONDA_BUILD_CROSS_COMPILATION@" = "1" ]; then
  _CMAKE_ARGS="${_CMAKE_ARGS} -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_PROCESSOR=@UNAME_MACHINE@ -DCMAKE_SYSTEM_VERSION=@UNAME_KERNEL_RELEASE@"
  _MESON_ARGS="${_MESON_ARGS} --cross-file $BUILD_PREFIX/meson_cross_file.txt"
  echo "[host_machine]" > $BUILD_PREFIX/meson_cross_file.txt
  echo "system = 'darwin'" >> $BUILD_PREFIX/meson_cross_file.txt
  echo "cpu = '@UNAME_MACHINE@'" >> $BUILD_PREFIX/meson_cross_file.txt
  echo "cpu_family = '@MESON_CPU_FAMILY@'" >> $BUILD_PREFIX/meson_cross_file.txt
  echo "endian = 'little'" >> $BUILD_PREFIX/meson_cross_file.txt
fi

I believe this is due to Conda-Forge's feedstock continuous integration not having access to Apple Silicon as they build the lovely binaries we all use (they are using Intel/AMD arches to build Arm64; i.e. cross compiling). Which then is set and propagates to those actually using said hardware.

Unfortunately, this creates an always true activation:

if [ "1" = "1" ]; then
  _CMAKE_ARGS="${_CMAKE_ARGS} -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_SYSTEM_VERSION=13.4.0"
  _MESON_ARGS="${_MESON_ARGS} --cross-file $BUILD_PREFIX/meson_cross_file.txt"
  echo "[host_machine]" > $BUILD_PREFIX/meson_cross_file.txt
  echo "system = 'darwin'" >> $BUILD_PREFIX/meson_cross_file.txt
  echo "cpu = 'x86_64'" >> $BUILD_PREFIX/meson_cross_file.txt
  echo "cpu_family = 'x86_64'" >> $BUILD_PREFIX/meson_cross_file.txt
  echo "endian = 'little'" >> $BUILD_PREFIX/meson_cross_file.txt
fi

While not a fix, you can set BUILD_PREFIX to some writable area just before the activation event:

BUILD_PREFIX="/some/writable/dir"
conda activate test

But, I would sooner just ignore this message. BUILD_PREFIX is really only used during conda build operations (as far as I know).