Repository: conda/conda

Issue:
Post-link script output is ill-formatted 
We observed the problem in conda-forge/openmpi-feedstock#56:
```bash
$ conda create -n mpi_test -c conda-forge python=3.7 mpi4py openmpi
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.7.12
  latest version: 4.8.3

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /home/leofang/miniconda3/envs/mpi_test

  added / updated specs:
    - mpi4py
    - openmpi
    - python=3.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2020.4.5.1 |       hecc5488_0         146 KB  conda-forge
    certifi-2020.4.5.1         |   py37hc8dfbb8_0         151 KB  conda-forge
    mpi-1.0                    |          openmpi           4 KB  conda-forge
    mpi4py-3.0.3               |   py37hbfacf26_1         647 KB  conda-forge
    openmpi-4.0.2              |       hdf1f1ad_4         3.9 MB  conda-forge
    setuptools-46.1.3          |   py37hc8dfbb8_0         634 KB  conda-forge
    xz-5.2.5                   |       h516909a_0         430 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         5.9 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-0_gnu
  ca-certificates    conda-forge/linux-64::ca-certificates-2020.4.5.1-hecc5488_0
  certifi            conda-forge/linux-64::certifi-2020.4.5.1-py37hc8dfbb8_0
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.34-h53a641e_0
  libffi             conda-forge/linux-64::libffi-3.2.1-he1b5a44_1007
  libgcc-ng          conda-forge/linux-64::libgcc-ng-9.2.0-h24d8f2e_2
  libgfortran-ng     conda-forge/linux-64::libgfortran-ng-7.3.0-hdf63c60_5
  libgomp            conda-forge/linux-64::libgomp-9.2.0-h24d8f2e_2
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-9.2.0-hdf63c60_2
  mpi                conda-forge/linux-64::mpi-1.0-openmpi
  mpi4py             conda-forge/linux-64::mpi4py-3.0.3-py37hbfacf26_1
  ncurses            conda-forge/linux-64::ncurses-6.1-hf484d3e_1002
  openmpi            conda-forge/linux-64::openmpi-4.0.2-hdf1f1ad_4
  openssl            conda-forge/linux-64::openssl-1.1.1f-h516909a_0
  pip                conda-forge/noarch::pip-20.0.2-py_2
  python             conda-forge/linux-64::python-3.7.6-h8356626_5_cpython
  python_abi         conda-forge/linux-64::python_abi-3.7-1_cp37m
  readline           conda-forge/linux-64::readline-8.0-hf8c457e_0
  setuptools         conda-forge/linux-64::setuptools-46.1.3-py37hc8dfbb8_0
  sqlite             conda-forge/linux-64::sqlite-3.30.1-hcee41ef_0
  tk                 conda-forge/linux-64::tk-8.6.10-hed695b0_0
  wheel              conda-forge/noarch::wheel-0.34.2-py_1
  xz                 conda-forge/linux-64::xz-5.2.5-h516909a_0
  zlib               conda-forge/linux-64::zlib-1.2.11-h516909a_1006


Proceed ([y]/n)? 


Downloading and Extracting Packages
openmpi-4.0.2        | 3.9 MB    | ############################################################################################################################ | 100% 
mpi4py-3.0.3         | 647 KB    | ############################################################################################################################ | 100% 
mpi-1.0              | 4 KB      | ############################################################################################################################ | 100% 
ca-certificates-2020 | 146 KB    | ############################################################################################################################ | 100% 
setuptools-46.1.3    | 634 KB    | ############################################################################################################################ | 100% 
certifi-2020.4.5.1   | 151 KB    | ############################################################################################################################ | 100% 
xz-5.2.5             | 430 KB    | ############################################################################################################################ | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: \ b' \nFor Linux 64, Open MPI is built with CUDA awareness but this support is disabled by default.\nTo enable it, please set the environmental variable OMPI_MCA_opal_cuda_support=true before\nlaunching your MPI processes. Equivalently, you can set the MCA parameter in the command line:\nmpiexec --mca opal_cuda_support 1 ...\n \n'
done
#
# To activate this environment, use
#
#     $ conda activate mpi_test
#
# To deactivate an active environment, use
#
#     $ conda deactivate
```
All post-link output is crushed into one line in "Executing transaction"; the newline is not respected. This makes it impossible for our users to notice/read the warning...



Discussion:

Resolving patch:
diff --git a/conda/core/link.py b/conda/core/link.py
--- a/conda/core/link.py
+++ b/conda/core/link.py
@@ -1222,7 +1222,7 @@ def messages(prefix):
                 m = fi.read()
                 if hasattr(m, "decode"):
                     m = m.decode('utf-8')
-                print(m.encode('utf-8'), file=sys.stderr if context.json else sys.stdout)
+                print(m, file=sys.stderr if context.json else sys.stdout)
                 return m
     finally:
         rm_rf(path)


Test patch: