Repository: conda/conda-build

Issue:
error reading DESCRIPTION
I originally reported this error in issue #2750, but that issue is closed, and I'm still having the same problem with `conda-build 3.8.0` (I just updated it). 

The steps that generated the error:

```
conda skeleton cran fd --recursive --update-policy overwrite
conda-build r-fd/
```

The error:

```
Error: error reading file '/ebio/abt3_projects/software/dev/miniconda3_dev/conda-bld/r-fd_1522864702532/work/DESCRIPTION'
Traceback (most recent call last):
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 420, in main
    execute(sys.argv[1:])
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 411, in execute
    verify=args.verify)
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/api.py", line 199, in build
    notest=notest, need_source_download=need_source_download, variants=variants)
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/build.py", line 2105, in build_tree
    notest=notest,
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/build.py", line 1377, in build
    utils.check_call_env(cmd, env=env, cwd=src_dir, stats=build_stats)
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/utils.py", line 301, in check_call_env
    return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
  File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda_build/utils.py", line 280, in _func_defaulting_env_to_os_environ
    raise subprocess.CalledProcessError(proc.returncode, _args)
subprocess.CalledProcessError: Command '['/bin/bash', '-e', '/ebio/abt3_projects/software/dev/miniconda3_dev/conda-bld/r-fd_1522864702532/work/conda_build.sh']' returned non-zero exit status 1.
```

The DESCRIPTION file:

```
Package: FD
Type: Package
Title: Measuring functional diversity (FD) from multiple traits, and
        other tools for functional ecology
Version: 1.0-12
Date: 2014-19-08
Binary file DESCRIPTION.old matches
```

Conda info:

```
$ conda info

     active environment : R_pkg_build
    active env location : /ebio/abt3_projects/software/dev/miniconda3_dev/envs/R_pkg_build
            shell level : 1
       user config file : /ebio/abt3/nyoungblut/.condarc
 populated config files : /ebio/abt3_projects/software/dev/miniconda3_dev/.condarc
                          /ebio/abt3/nyoungblut/.condarc
          conda version : 4.5.0
    conda-build version : 3.8.0
         python version : 3.6.5.final.0
       base environment : /ebio/abt3_projects/software/dev/miniconda3_dev  (writable)
           channel URLs : https://conda.anaconda.org/bioconda/linux-64
                          https://conda.anaconda.org/bioconda/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://conda.anaconda.org/r/linux-64
                          https://conda.anaconda.org/r/noarch
                          https://conda.anaconda.org/qiime2/linux-64
                          https://conda.anaconda.org/qiime2/noarch
          package cache : /ebio/abt3_projects/software/dev/miniconda3_dev/pkgs
                          /ebio/abt3/nyoungblut/.conda/pkgs
       envs directories : /ebio/abt3_projects/software/dev/miniconda3_dev/envs
                          /ebio/abt3/nyoungblut/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.0 requests/2.18.4 CPython/3.6.5 Linux/4.4.67 ubuntu/16.04 glibc/2.23
                UID:GID : 6354:350
             netrc file : None
           offline mode : False
```

Is there anything that I can change in the `build.sh` or `meta.yaml` files in `r-fd/` to fix this issue? Maybe the line: `grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION`, given that the DESCRIPTION file doesn't seem to include "Priority"?


Discussion:
I think you should be able to remove whatever in meta.yaml is trying to read that description.  Whether it is in build.sh or meta.yaml - either way, just cut it.  I'm not sure what purpose it serves, exactly, without taking a closer look, but it's almost certainly fine to omit whatever data it's reading there.
That's the thing, I don't know what I'm looking for. All that I can find in either file that mentions DESCRIPTION is:

```
  mv DESCRIPTION DESCRIPTION.old
  grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION
```

in the `meta.yaml` file, but I'm guessing that's not the problem.  Any ideas on what could be trying to read the description?

It seems that the DESCRIPTION file for the `fd` package is missing many fields found in other packages. The `PMA` package for example:

```Package: PMA
Type: Package
Title: Penalized Multivariate Analysis
Version: 1.0.9
Date: 2013-03-23
Author: Daniela Witten and Rob Tibshirani and Sam Gross and
        Balasubramanian Narasimhan
Maintainer: Daniela Witten <dwitten@u.washington.edu>
Description: Performs Penalized Multivariate Analysis: a penalized
        matrix decomposition, sparse principal components analysis, and
        sparse canonical correlation analysis, described in the
        following papers: (1) Witten, Tibshirani and Hastie (2009) A
        penalized matrix decomposition, with applications to sparse
        principal components and canonical correlation analysis.
        Biostatistics 10(3):515-534. (2) Witten and Tibshirani (2009)
        Extensions of sparse canonical correlation analysis, with
        applications to genomic data. Statistical Applications in
        Genetics and Molecular Biology 8(1): Article 28.
License: GPL (>= 2)
Depends: R (>= 2.10), plyr, impute
Packaged: 2013-03-25 07:06:23 UTC; dwitten
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-03-25 08:26:26
```

Which, if any, of these fields are required?
I've spent a lot of time trying to figure this out. My basic approach has been to compare the `FD` package description to other packages that build successfully. The description for `FD` (https://cran.r-project.org/src/contrib/FD_1.0-12.tar.gz) is:

```
Package: FD
Type: Package
Title: Measuring functional diversity (FD) from multiple traits, and
        other tools for functional ecology
Version: 1.0-12
Date: 2014-19-08
Author: Etienne LalibertÈ, Pierre Legendre, Bill Shipley
Maintainer: Etienne LalibertÈ <etiennelaliberte@gmail.com>
Description: FD is a package to compute different multidimensional FD indices. It implements a distance-based framework to measure FD that allows any number and type of functional traits, and can also consider species relative abundances. It also contains other useful tools for functional ecology.
License: GPL-2
LazyLoad: yes
LazyData: yes
Depends: ade4, ape, geometry, vegan
Encoding: latin1
Packaged: 2014-08-19 09:49:14 UTC; 00073639
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2014-08-19 13:42:17
```

The resulting DESCRIPTION file during the build is:

```
Package: FD
Type: Package
Title: Measuring functional diversity (FD) from multiple traits, and
        other tools for functional ecology
Version: 1.0-12
Date: 2014-19-08
Binary file DESCRIPTION.old matches
```

Now for plyr (https://cran.r-project.org/src/contrib/plyr_1.8.4.tar.gz), the package DESCRIPTION is:

```
Package: plyr
Version: 1.8.4
Title: Tools for Splitting, Applying and Combining Data
Description: A set of tools that solves a common set of problems: you
    need to break a big problem down into manageable pieces, operate on each
    piece and then put all the pieces back together.  For example, you might
    want to fit a model to each spatial location or time point in your study,
    summarise data by panels or collapse high-dimensional arrays to simpler
    summary statistics. The development of 'plyr' has been generously supported
    by 'Becton Dickinson'.
Authors@R: person("Hadley", "Wickham", , "hadley@rstudio.com", c("aut", "cre"))
URL: http://had.co.nz/plyr, https://github.com/hadley/plyr
BugReports: https://github.com/hadley/plyr/issues
Depends: R (>= 3.1.0)
Imports: Rcpp (>= 0.11.0)
LinkingTo: Rcpp
Suggests: abind, testthat, tcltk, foreach, doParallel, itertools,
        iterators, covr
License: MIT + file LICENSE
LazyData: true
RoxygenNote: 5.0.1
NeedsCompilation: yes
Packaged: 2016-06-07 19:58:36 UTC; hadley
Author: Hadley Wickham [aut, cre]
Maintainer: Hadley Wickham <hadley@rstudio.com>
Repository: CRAN
Date/Publication: 2016-06-08 10:40:15
```

...and the resulting conda-build DESCRIPTION is:

```
Package: plyr
Version: 1.8.4
Title: Tools for Splitting, Applying and Combining Data
Description: A set of tools that solves a common set of problems: you
    need to break a big problem down into manageable pieces, operate on each
    piece and then put all the pieces back together.  For example, you might
    want to fit a model to each spatial location or time point in your study,
    summarise data by panels or collapse high-dimensional arrays to simpler
    summary statistics. The development of 'plyr' has been generously supported
    by 'Becton Dickinson'.
Authors@R: person("Hadley", "Wickham", , "hadley@rstudio.com", c("aut", "cre"))
URL: http://had.co.nz/plyr, https://github.com/hadley/plyr
BugReports: https://github.com/hadley/plyr/issues
Depends: R (>= 3.1.0)
Imports: Rcpp (>= 0.11.0)
LinkingTo: Rcpp
Suggests: abind, testthat, tcltk, foreach, doParallel, itertools,
        iterators, covr
License: MIT + file LICENSE
LazyData: true
RoxygenNote: 5.0.1
NeedsCompilation: yes
Packaged: 2016-06-07 19:58:36 UTC; hadley
Author: Hadley Wickham [aut, cre]
Maintainer: Hadley Wickham <hadley@rstudio.com>
Repository: CRAN
Date/Publication: 2016-06-08 10:40:15
Built: R 3.4.1; x86_64-pc-linux-gnu; 2017-08-20 05:58:14 UTC; unix
```

One difference I see with `FD`, is the lack of `Authors@R`. Could this be why the conda-build DESCRIPTION is lacking so many fields? Could it be the `È` in the first author's name?
Yes, that character may cause problems.  Are you using Python 2.7 in your root env?  If so, maybe try from a Python 3 installation - it handles non-ascii characters much better.  We can probably improve handling in conda-build across all of the pythons, but this can be a lot of work to get right.
Oops, I see from your conda info above that yes, you are already on python 3.6.  So no dice there.  We need a fix for conda-build.  You may need to manually create or augment this recipe in the meantime.
So, I was table to get `conda-build` to work for the `fd` R package. I had to fork the Github repo, then edit the DESCRIPTION to remove the "é" in the author's name. I then created a new release tag and ran `conda-build` with the Github url & tag from my forked repo. So it appears that conda-build can't handle "é" in DESCRIPTION files of R packages (I'm using conda-build 3.9.1)
I don't think this is a conda-build bug, actually.  The failure is in code in the generated conda_build.sh, which looks like this:

```
conda activate --stack "/Users/msarahan/miniconda3/conda-bld/r-fd_1524844118693/_build_env"
#!/bin/bash

if [[ $target_platform =~ linux.* ]] || [[ $target_platform == win-32 ]] || [[ $target_platform == win-64 ]] || [[ $target_platform == osx-64 ]]; then
  export DISABLE_AUTOBREW=1
  mv DESCRIPTION DESCRIPTION.old
  grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION
  $R CMD INSTALL --build .
else
  mkdir -p $PREFIX/lib/R/library/FD
  mv * $PREFIX/lib/R/library/FD
fi
```

I think it is failing on the grep lines, which are created here:

https://github.com/conda/conda-build/blob/master/conda_build/skeletons/cran.py#L125
https://github.com/conda/conda-build/blob/master/conda_build/skeletons/cran.py#L141

Note that the skeleton is generated fine, it is only later that reading the file fails.

The package builds fine for me.  This then suggests that you may not have your computer's LOCALE stuff set.  That's a common problem with docker containers especially.  See https://stackoverflow.com/a/28406007/1170370

I'm closing this issue, but I'd be happy to reopen it if you can prove that it is actually a problem in conda-build.
@msarahan I'm actually encountering this issue now with the recipe for the CRAN package `snpassoc` generated with `conda skeleton` on my Ubuntu 16.04 VM. I have not been successful at changing the locale settings to get this to work. I certainly accept that this isn't conda build's fault _per se_ but once I figure out a fix I think we should either bake it into the skeleton output or the documentation.

Resolving patch:
diff --git a/conda_build/skeletons/cran.py b/conda_build/skeletons/cran.py
--- a/conda_build/skeletons/cran.py
+++ b/conda_build/skeletons/cran.py
@@ -122,7 +122,7 @@
 
 # R refuses to build packages that mark themselves as Priority: Recommended
 mv DESCRIPTION DESCRIPTION.old
-grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION
+grep -va '^Priority: ' DESCRIPTION.old > DESCRIPTION
 $R CMD INSTALL --build .
 
 # Add more build steps here, if they are necessary.


Test patch: