Repository: conda/conda-build

Issue:
Conda build (with mambabuild) breaks with KeyError in display_actions() when cross compiling
### Checklist

- [X] I added a descriptive title
- [X] I searched open reports and couldn't find a duplicate

### What happened?

Conda-forge feedstock builds for https://github.com/conda-forge/lalsimulation-feedstock/pull/59 are failing when packaging one of the `outputs` packages, with the error:

```pytb
Packaging liblalsimulation
INFO:conda_build.build:Packaging liblalsimulation
Reloading output folder: /Users/runner/miniforge3/conda-bld
Traceback (most recent call last):
  File "/Users/runner/miniforge3/bin/conda-mambabuild", line 10, in <module>
    sys.exit(main())
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/boa/cli/mambabuild.py", line 256, in main
    call_conda_build(action, config)
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/boa/cli/mambabuild.py", line 228, in call_conda_build
    result = api.build(
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/api.py", line 180, in build
    return build_tree(
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/build.py", line 3078, in build_tree
    packages_from_this = build(metadata, stats,
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/build.py", line 2313, in build
    environ.create_env(m.config.host_prefix, host_actions, env='host',
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/environ.py", line 1052, in create_env
    display_actions(actions, index)
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda/exports.py", line 213, in display_actions
    actions['LINK'] = [index[d] for d in actions['LINK']]
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda/exports.py", line 213, in <listcomp>
    actions['LINK'] = [index[d] for d in actions['LINK']]
KeyError: Dist(channel='conda-forge', dist_name='bzip2-1.0.8-h3422bc3_4', name='bzip2', fmt='.tar.bz2', version='1.0.8', build_string='h3422bc3_4', build_number=4, base_url=None, platform=None)
```

See the build log [here](https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=697357&view=logs&j=385a3385-ae8b-54d1-9abe-3c614f74cb73&t=a5f9d343-149e-5621-6ab9-f0278009be04).

This only happens on true cross-compilation of `osx-arm64` packages from `osx-64`, and is reproducible on my home machine as well as on Azure pipelines.

### Conda Info

```shell
active environment : base
    active env location : /Users/runner/miniforge3
            shell level : 1
       user config file : /Users/runner/.condarc
 populated config files : /Users/runner/miniforge3/.condarc
          conda version : 23.1.0
    conda-build version : 3.24.0
         python version : 3.10.10.final.0
       virtual packages : __archspec=1=x86_64
                          __osx=11.7.6=0
                          __unix=0=0
       base environment : /Users/runner/miniforge3  (writable)
      conda av data dir : /Users/runner/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/runner/miniforge3/pkgs
                          /Users/runner/.conda/pkgs
       envs directories : /Users/runner/miniforge3/envs
                          /Users/runner/.conda/envs
               platform : osx-64
             user-agent : conda/23.1.0 requests/2.28.2 CPython/3.10.10 Darwin/20.6.0 OSX/11.7.6
                UID:GID : 501:20
             netrc file : None
           offline mode : False
```


### Conda Config

```shell
==> /Users/runner/miniforge3/.condarc <==
add_pip_as_python_dependency: False
auto_update_conda: False
aggressive_update_packages:
  - ca-certificates
  - certifi
channel_priority: strict
channels:
  - conda-forge
show_channel_urls: True
conda_build:
  pkg_format: 2
  zstd_compression_level: 19
```


### Conda list

```shell
# packages in environment at /Users/runner/miniforge3:
#
# Name                    Version                   Build  Channel
anaconda-client           1.11.2             pyhd8ed1ab_0    conda-forge
anaconda-project          0.11.1             pyhd8ed1ab_0    conda-forge
anyio                     3.6.2              pyhd8ed1ab_0    conda-forge
attrs                     22.2.0             pyh71513ae_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.12.2             pyha770c72_0    conda-forge
boa                       0.14.0             pyhd8ed1ab_4    conda-forge
brotlipy                  0.7.0           py310h90acd4f_1005    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
c-ares                    1.18.1               h0d85af4_0    conda-forge
ca-certificates           2022.12.7            h033912b_0    conda-forge
cctools                   973.0.1             h40f6528_13    conda-forge
cctools_osx-64            973.0.1             h5676edf_13    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py310ha78151a_3    conda-forge
chardet                   5.1.0           py310h2ec42d9_0    conda-forge
charset-normalizer        3.1.0              pyhd8ed1ab_0    conda-forge
click                     8.1.3           unix_pyhd8ed1ab_2    conda-forge
clyent                    1.2.2                      py_1    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
conda                     23.1.0          py310h2ec42d9_0    conda-forge
conda-build               3.24.0          py310h2ec42d9_1    conda-forge
conda-env                 2.6.0                         1    conda-forge
conda-forge-ci-setup      3.30.1          py310h22f808f_100    conda-forge
conda-pack                0.7.0              pyh6c4a22f_0    conda-forge
conda-package-handling    2.0.2              pyh38be061_0    conda-forge
conda-package-streaming   0.7.0              pyhd8ed1ab_1    conda-forge
cryptography              40.0.1          py310hdd0c95c_0    conda-forge
curl                      7.88.1               h6df9250_1    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
filelock                  3.12.0             pyhd8ed1ab_0    conda-forge
fmt                       9.1.0                hb8565cd_0    conda-forge
freetype                  2.12.1               h3f81eb7_1    conda-forge
gettext                   0.21.1               h8a4c099_0    conda-forge
git                       2.40.1          pl5321h5c607e1_0    conda-forge
glob2                     0.7                        py_0    conda-forge
icu                       72.1                 h7336db1_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        6.6.0              pyha770c72_0    conda-forge
importlib_resources       5.12.0             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.2.0              pyhd8ed1ab_0    conda-forge
jq                        1.6               hc929b4f_1000    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
jupyter_core              5.3.0           py310h2ec42d9_0    conda-forge
krb5                      1.20.1               h049b76e_0    conda-forge
lcms2                     2.15                 h2dcdeff_1    conda-forge
ld64                      609                 ha02d983_13    conda-forge
ld64_osx-64               609                 hbfe4790_13    conda-forge
lerc                      4.0.0                hb486fe8_0    conda-forge
libarchive                3.6.2                h6d8d9f1_0    conda-forge
libcurl                   7.88.1               h6df9250_1    conda-forge
libcxx                    16.0.0               h71dddab_0    conda-forge
libdeflate                1.18                 hac1461d_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libev                     4.33                 haf1e3a3_1    conda-forge
libexpat                  2.5.0                hf0c8a7f_1    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libiconv                  1.17                 hac89ed1_0    conda-forge
libjpeg-turbo             2.1.5.1              hb7f2c08_0    conda-forge
liblief                   0.12.3               hf0c8a7f_0    conda-forge
libllvm16                 16.0.1               h7001e86_0    conda-forge
libmamba                  1.4.1                h9d281b0_0    conda-forge
libmambapy                1.4.1           py310hb15139c_0    conda-forge
libnghttp2                1.52.0               he2ab024_0    conda-forge
libpng                    1.6.39               ha978bb4_0    conda-forge
libsolv                   0.7.23               hbc0c0cd_0    conda-forge
libsqlite                 3.40.0               ha978bb4_0    conda-forge
libssh2                   1.10.0               h47af595_3    conda-forge
libtiff                   4.5.0                hedf67fa_6    conda-forge
libwebp-base              1.3.0                hb7f2c08_0    conda-forge
libxcb                    1.13              h0d85af4_1004    conda-forge
libxml2                   2.10.3               h554bb67_6    conda-forge
libzlib                   1.2.13               hfd90126_4    conda-forge
lz4-c                     1.9.4                hf0c8a7f_0    conda-forge
lzo                       2.10              haf1e3a3_1000    conda-forge
mamba                     1.4.1           py310h6bde348_0    conda-forge
markdown-it-py            2.2.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.2           py310h90acd4f_0    conda-forge
mdurl                     0.1.0              pyhd8ed1ab_0    conda-forge
nbformat                  5.8.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h96cf925_1    conda-forge
oniguruma                 6.9.8                hac89ed1_0    conda-forge
openjpeg                  2.5.0                h13ac156_2    conda-forge
openssl                   3.1.0                h8a1eda9_2    conda-forge
packaging                 23.1               pyhd8ed1ab_0    conda-forge
patch                     2.7.6             hbcf498f_1002    conda-forge
pcre2                     10.40                h1c4e4bc_0    conda-forge
perl                      5.32.1          2_h0d85af4_perl5    conda-forge
pillow                    9.5.0           py310h6b2f720_0    conda-forge
pip                       23.1.2             pyhd8ed1ab_0    conda-forge
pkginfo                   1.9.6              pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
platformdirs              3.4.0              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
prompt-toolkit            3.0.38             pyha770c72_0    conda-forge
prompt_toolkit            3.0.38               hd8ed1ab_0    conda-forge
psutil                    5.9.5           py310h90acd4f_0    conda-forge
pthread-stubs             0.4               hc929b4f_1001    conda-forge
py-lief                   0.12.3          py310h7a76584_0    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pycosat                   0.6.4           py310h90acd4f_1    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.15.1             pyhd8ed1ab_0    conda-forge
pyopenssl                 23.1.1             pyhd8ed1ab_0    conda-forge
pyrsistent                0.19.3          py310h90acd4f_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.10.10         he7542f4_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.16.3             pyhd8ed1ab_0    conda-forge
python-libarchive-c       4.0             py310h2ec42d9_2    conda-forge
python_abi                3.10                    3_cp310    conda-forge
pytz                      2023.3             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py310h90acd4f_5    conda-forge
readline                  8.2                  h9e318b2_1    conda-forge
reproc                    14.2.4               hb7f2c08_0    conda-forge
reproc-cpp                14.2.4               hf0c8a7f_0    conda-forge
requests                  2.28.2             pyhd8ed1ab_1    conda-forge
requests-toolbelt         0.10.1             pyhd8ed1ab_0    conda-forge
rich                      13.3.4             pyhd8ed1ab_0    conda-forge
ripgrep                   13.0.0               hbbacdb1_2    conda-forge
ruamel.yaml               0.17.21         py310h90acd4f_3    conda-forge
ruamel.yaml.clib          0.2.7           py310h90acd4f_1    conda-forge
ruamel_yaml               0.15.80         py310h90acd4f_1008    conda-forge
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
shyaml                    0.6.2              pyhd3deb0d_0    conda-forge
sigtool                   0.1.3                h88f4db0_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
tapi                      1100.0.11            h9ce4665_0    conda-forge
tk                        8.6.12               h5dbffcc_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
tornado                   6.3             py310h90acd4f_0    conda-forge
tqdm                      4.65.0             pyhd8ed1ab_1    conda-forge
traitlets                 5.9.0              pyhd8ed1ab_0    conda-forge
typing-extensions         4.5.0                hd8ed1ab_0    conda-forge
typing_extensions         4.5.0              pyha770c72_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
urllib3                   1.26.15            pyhd8ed1ab_0    conda-forge
watchgod                  0.8.2              pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.6              pyhd8ed1ab_0    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.9                h35c211d_0    conda-forge
xorg-libxdmcp             1.1.3                h35c211d_0    conda-forge
xz                        5.2.6                h775f41a_0    conda-forge
yaml                      0.2.5                h0d85af4_2    conda-forge
yaml-cpp                  0.7.0                hf0c8a7f_2    conda-forge
zipp                      3.15.0             pyhd8ed1ab_0    conda-forge
zstandard                 0.19.0          py310h3cf44b0_1    conda-forge
zstd                      1.5.2                hbc0c0cd_6    conda-forge
```


### Additional Context

@xhochy has reported seeing similar issues when cross-compiling on linux, see https://github.com/conda-forge/rust-feedstock/pull/130#issuecomment-1464888888.

This happens independently of the use of `mambabuild`. Builds using standard `conda-build` without `boa` also exhibit the same failure.
Conda build (with mambabuild) breaks with KeyError in display_actions() when cross compiling
### Checklist

- [X] I added a descriptive title
- [X] I searched open reports and couldn't find a duplicate

### What happened?

Conda-forge feedstock builds for https://github.com/conda-forge/lalsimulation-feedstock/pull/59 are failing when packaging one of the `outputs` packages, with the error:

```pytb
Packaging liblalsimulation
INFO:conda_build.build:Packaging liblalsimulation
Reloading output folder: /Users/runner/miniforge3/conda-bld
Traceback (most recent call last):
  File "/Users/runner/miniforge3/bin/conda-mambabuild", line 10, in <module>
    sys.exit(main())
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/boa/cli/mambabuild.py", line 256, in main
    call_conda_build(action, config)
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/boa/cli/mambabuild.py", line 228, in call_conda_build
    result = api.build(
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/api.py", line 180, in build
    return build_tree(
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/build.py", line 3078, in build_tree
    packages_from_this = build(metadata, stats,
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/build.py", line 2313, in build
    environ.create_env(m.config.host_prefix, host_actions, env='host',
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/environ.py", line 1052, in create_env
    display_actions(actions, index)
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda/exports.py", line 213, in display_actions
    actions['LINK'] = [index[d] for d in actions['LINK']]
  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda/exports.py", line 213, in <listcomp>
    actions['LINK'] = [index[d] for d in actions['LINK']]
KeyError: Dist(channel='conda-forge', dist_name='bzip2-1.0.8-h3422bc3_4', name='bzip2', fmt='.tar.bz2', version='1.0.8', build_string='h3422bc3_4', build_number=4, base_url=None, platform=None)
```

See the build log [here](https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=697357&view=logs&j=385a3385-ae8b-54d1-9abe-3c614f74cb73&t=a5f9d343-149e-5621-6ab9-f0278009be04).

This only happens on true cross-compilation of `osx-arm64` packages from `osx-64`, and is reproducible on my home machine as well as on Azure pipelines.

### Conda Info

```shell
active environment : base
    active env location : /Users/runner/miniforge3
            shell level : 1
       user config file : /Users/runner/.condarc
 populated config files : /Users/runner/miniforge3/.condarc
          conda version : 23.1.0
    conda-build version : 3.24.0
         python version : 3.10.10.final.0
       virtual packages : __archspec=1=x86_64
                          __osx=11.7.6=0
                          __unix=0=0
       base environment : /Users/runner/miniforge3  (writable)
      conda av data dir : /Users/runner/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/runner/miniforge3/pkgs
                          /Users/runner/.conda/pkgs
       envs directories : /Users/runner/miniforge3/envs
                          /Users/runner/.conda/envs
               platform : osx-64
             user-agent : conda/23.1.0 requests/2.28.2 CPython/3.10.10 Darwin/20.6.0 OSX/11.7.6
                UID:GID : 501:20
             netrc file : None
           offline mode : False
```


### Conda Config

```shell
==> /Users/runner/miniforge3/.condarc <==
add_pip_as_python_dependency: False
auto_update_conda: False
aggressive_update_packages:
  - ca-certificates
  - certifi
channel_priority: strict
channels:
  - conda-forge
show_channel_urls: True
conda_build:
  pkg_format: 2
  zstd_compression_level: 19
```


### Conda list

```shell
# packages in environment at /Users/runner/miniforge3:
#
# Name                    Version                   Build  Channel
anaconda-client           1.11.2             pyhd8ed1ab_0    conda-forge
anaconda-project          0.11.1             pyhd8ed1ab_0    conda-forge
anyio                     3.6.2              pyhd8ed1ab_0    conda-forge
attrs                     22.2.0             pyh71513ae_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.12.2             pyha770c72_0    conda-forge
boa                       0.14.0             pyhd8ed1ab_4    conda-forge
brotlipy                  0.7.0           py310h90acd4f_1005    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
c-ares                    1.18.1               h0d85af4_0    conda-forge
ca-certificates           2022.12.7            h033912b_0    conda-forge
cctools                   973.0.1             h40f6528_13    conda-forge
cctools_osx-64            973.0.1             h5676edf_13    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py310ha78151a_3    conda-forge
chardet                   5.1.0           py310h2ec42d9_0    conda-forge
charset-normalizer        3.1.0              pyhd8ed1ab_0    conda-forge
click                     8.1.3           unix_pyhd8ed1ab_2    conda-forge
clyent                    1.2.2                      py_1    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
conda                     23.1.0          py310h2ec42d9_0    conda-forge
conda-build               3.24.0          py310h2ec42d9_1    conda-forge
conda-env                 2.6.0                         1    conda-forge
conda-forge-ci-setup      3.30.1          py310h22f808f_100    conda-forge
conda-pack                0.7.0              pyh6c4a22f_0    conda-forge
conda-package-handling    2.0.2              pyh38be061_0    conda-forge
conda-package-streaming   0.7.0              pyhd8ed1ab_1    conda-forge
cryptography              40.0.1          py310hdd0c95c_0    conda-forge
curl                      7.88.1               h6df9250_1    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
filelock                  3.12.0             pyhd8ed1ab_0    conda-forge
fmt                       9.1.0                hb8565cd_0    conda-forge
freetype                  2.12.1               h3f81eb7_1    conda-forge
gettext                   0.21.1               h8a4c099_0    conda-forge
git                       2.40.1          pl5321h5c607e1_0    conda-forge
glob2                     0.7                        py_0    conda-forge
icu                       72.1                 h7336db1_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        6.6.0              pyha770c72_0    conda-forge
importlib_resources       5.12.0             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.2.0              pyhd8ed1ab_0    conda-forge
jq                        1.6               hc929b4f_1000    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
jupyter_core              5.3.0           py310h2ec42d9_0    conda-forge
krb5                      1.20.1               h049b76e_0    conda-forge
lcms2                     2.15                 h2dcdeff_1    conda-forge
ld64                      609                 ha02d983_13    conda-forge
ld64_osx-64               609                 hbfe4790_13    conda-forge
lerc                      4.0.0                hb486fe8_0    conda-forge
libarchive                3.6.2                h6d8d9f1_0    conda-forge
libcurl                   7.88.1               h6df9250_1    conda-forge
libcxx                    16.0.0               h71dddab_0    conda-forge
libdeflate                1.18                 hac1461d_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libev                     4.33                 haf1e3a3_1    conda-forge
libexpat                  2.5.0                hf0c8a7f_1    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libiconv                  1.17                 hac89ed1_0    conda-forge
libjpeg-turbo             2.1.5.1              hb7f2c08_0    conda-forge
liblief                   0.12.3               hf0c8a7f_0    conda-forge
libllvm16                 16.0.1               h7001e86_0    conda-forge
libmamba                  1.4.1                h9d281b0_0    conda-forge
libmambapy                1.4.1           py310hb15139c_0    conda-forge
libnghttp2                1.52.0               he2ab024_0    conda-forge
libpng                    1.6.39               ha978bb4_0    conda-forge
libsolv                   0.7.23               hbc0c0cd_0    conda-forge
libsqlite                 3.40.0               ha978bb4_0    conda-forge
libssh2                   1.10.0               h47af595_3    conda-forge
libtiff                   4.5.0                hedf67fa_6    conda-forge
libwebp-base              1.3.0                hb7f2c08_0    conda-forge
libxcb                    1.13              h0d85af4_1004    conda-forge
libxml2                   2.10.3               h554bb67_6    conda-forge
libzlib                   1.2.13               hfd90126_4    conda-forge
lz4-c                     1.9.4                hf0c8a7f_0    conda-forge
lzo                       2.10              haf1e3a3_1000    conda-forge
mamba                     1.4.1           py310h6bde348_0    conda-forge
markdown-it-py            2.2.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.2           py310h90acd4f_0    conda-forge
mdurl                     0.1.0              pyhd8ed1ab_0    conda-forge
nbformat                  5.8.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h96cf925_1    conda-forge
oniguruma                 6.9.8                hac89ed1_0    conda-forge
openjpeg                  2.5.0                h13ac156_2    conda-forge
openssl                   3.1.0                h8a1eda9_2    conda-forge
packaging                 23.1               pyhd8ed1ab_0    conda-forge
patch                     2.7.6             hbcf498f_1002    conda-forge
pcre2                     10.40                h1c4e4bc_0    conda-forge
perl                      5.32.1          2_h0d85af4_perl5    conda-forge
pillow                    9.5.0           py310h6b2f720_0    conda-forge
pip                       23.1.2             pyhd8ed1ab_0    conda-forge
pkginfo                   1.9.6              pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
platformdirs              3.4.0              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
prompt-toolkit            3.0.38             pyha770c72_0    conda-forge
prompt_toolkit            3.0.38               hd8ed1ab_0    conda-forge
psutil                    5.9.5           py310h90acd4f_0    conda-forge
pthread-stubs             0.4               hc929b4f_1001    conda-forge
py-lief                   0.12.3          py310h7a76584_0    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pycosat                   0.6.4           py310h90acd4f_1    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.15.1             pyhd8ed1ab_0    conda-forge
pyopenssl                 23.1.1             pyhd8ed1ab_0    conda-forge
pyrsistent                0.19.3          py310h90acd4f_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.10.10         he7542f4_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.16.3             pyhd8ed1ab_0    conda-forge
python-libarchive-c       4.0             py310h2ec42d9_2    conda-forge
python_abi                3.10                    3_cp310    conda-forge
pytz                      2023.3             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py310h90acd4f_5    conda-forge
readline                  8.2                  h9e318b2_1    conda-forge
reproc                    14.2.4               hb7f2c08_0    conda-forge
reproc-cpp                14.2.4               hf0c8a7f_0    conda-forge
requests                  2.28.2             pyhd8ed1ab_1    conda-forge
requests-toolbelt         0.10.1             pyhd8ed1ab_0    conda-forge
rich                      13.3.4             pyhd8ed1ab_0    conda-forge
ripgrep                   13.0.0               hbbacdb1_2    conda-forge
ruamel.yaml               0.17.21         py310h90acd4f_3    conda-forge
ruamel.yaml.clib          0.2.7           py310h90acd4f_1    conda-forge
ruamel_yaml               0.15.80         py310h90acd4f_1008    conda-forge
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
shyaml                    0.6.2              pyhd3deb0d_0    conda-forge
sigtool                   0.1.3                h88f4db0_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
tapi                      1100.0.11            h9ce4665_0    conda-forge
tk                        8.6.12               h5dbffcc_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
tornado                   6.3             py310h90acd4f_0    conda-forge
tqdm                      4.65.0             pyhd8ed1ab_1    conda-forge
traitlets                 5.9.0              pyhd8ed1ab_0    conda-forge
typing-extensions         4.5.0                hd8ed1ab_0    conda-forge
typing_extensions         4.5.0              pyha770c72_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
urllib3                   1.26.15            pyhd8ed1ab_0    conda-forge
watchgod                  0.8.2              pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.6              pyhd8ed1ab_0    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.9                h35c211d_0    conda-forge
xorg-libxdmcp             1.1.3                h35c211d_0    conda-forge
xz                        5.2.6                h775f41a_0    conda-forge
yaml                      0.2.5                h0d85af4_2    conda-forge
yaml-cpp                  0.7.0                hf0c8a7f_2    conda-forge
zipp                      3.15.0             pyhd8ed1ab_0    conda-forge
zstandard                 0.19.0          py310h3cf44b0_1    conda-forge
zstd                      1.5.2                hbc0c0cd_6    conda-forge
```


### Additional Context

@xhochy has reported seeing similar issues when cross-compiling on linux, see https://github.com/conda-forge/rust-feedstock/pull/130#issuecomment-1464888888.

This happens independently of the use of `mambabuild`. Builds using standard `conda-build` without `boa` also exhibit the same failure.


Discussion:
I have found that the issue is because the `subdir` variable in the `conda_build.build.build()` function is being set once outside of the `outputs` loop:

https://github.com/conda/conda-build/blob/3e006a2c6e41637ae39bc38492c051ce0df2072a/conda_build/build.py#L2705-L2710

 and then set again towards the end of the loop:

https://github.com/conda/conda-build/blob/3e006a2c6e41637ae39bc38492c051ce0df2072a/conda_build/build.py#L2895-L2902

The means that if the recipe includes multiple outputs, _and_ a subset of those outputs are `noarch`, then the builds will break for any subsequent non-`noarch` outputs.

The simplest solution is to just use a unique variable name for that second, end-of-loop, reindexing subdir. I will post a PR.
I have found that the issue is because the `subdir` variable in the `conda_build.build.build()` function is being set once outside of the `outputs` loop:

https://github.com/conda/conda-build/blob/3e006a2c6e41637ae39bc38492c051ce0df2072a/conda_build/build.py#L2705-L2710

 and then set again towards the end of the loop:

https://github.com/conda/conda-build/blob/3e006a2c6e41637ae39bc38492c051ce0df2072a/conda_build/build.py#L2895-L2902

The means that if the recipe includes multiple outputs, _and_ a subset of those outputs are `noarch`, then the builds will break for any subsequent non-`noarch` outputs.

The simplest solution is to just use a unique variable name for that second, end-of-loop, reindexing subdir. I will post a PR.

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -2895,14 +2895,14 @@ def build(
                     # must rebuild index because conda has no way to incrementally add our last
                     #    package to the index.
 
-                    subdir = (
+                    index_subdir = (
                         "noarch"
                         if (m.noarch or m.noarch_python)
                         else m.config.host_subdir
                     )
                     if m.is_cross:
                         get_build_index(
-                            subdir=subdir,
+                            subdir=index_subdir,
                             bldpkgs_dir=m.config.bldpkgs_dir,
                             output_folder=m.config.output_folder,
                             channel_urls=m.config.channel_urls,
@@ -2913,7 +2913,7 @@ def build(
                             clear_cache=True,
                         )
                     get_build_index(
-                        subdir=subdir,
+                        subdir=index_subdir,
                         bldpkgs_dir=m.config.bldpkgs_dir,
                         output_folder=m.config.output_folder,
                         channel_urls=m.config.channel_urls,


Test patch: