Closed kalefranz closed 2 years ago
This is conda-build, but I’m who introduced the issue. I’ll have a PR to conda-build soon.
Sent from my iPhone
On Dec 5, 2017, at 12:20 AM, Dave Hirschfeld notifications@github.com wrote:
I'm trying to mirror packages in an internal repo for use in an offline install. This has worked for years but today when trying to create a clean repository the conda index command failed with the below error:
updating: zlib-1.2.11-vc14_0.tar.bz2 Traceback (most recent call last): File "C:\Miniconda3\Scripts\conda-index-script.py", line 10, in sys.exit(main()) File "C:\Miniconda3\lib\site-packages\conda_build\cli\main_index.py", line 75, in main return execute(sys.argv[1:]) File "C:\Miniconda3\lib\site-packages\conda_build\cli\main_index.py", line 71, in execute channel_name=args.channel_name) File "C:\Miniconda3\lib\site-packages\conda_build\api.py", line 367, in update_index locking=config.locking, timeout=config.timeout, channel_name=channel_name) File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 147, in update_index channel_name) File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 246, in update_subdir_index json.dump(recipe, fo, indent=2, sort_keys=True) File "C:\Miniconda3\lib\json\__init__.py", line 179, in dump for chunk in iterable: File "C:\Miniconda3\lib\json\encoder.py", line 430, in _iterencode yield from _iterencode_dict(o, _current_indent_level) File "C:\Miniconda3\lib\json\encoder.py", line 404, in _iterencode_dict yield from chunks File "C:\Miniconda3\lib\json\encoder.py", line 404, in _iterencode_dict yield from chunks File "C:\Miniconda3\lib\json\encoder.py", line 404, in _iterencode_dict yield from chunks File "C:\Miniconda3\lib\json\encoder.py", line 437, in _iterencode o = _default(o) File "C:\Miniconda3\lib\json\encoder.py", line 180, in default o.__class__.__name__) TypeError: Object of type 'method' is not JSON serializable This final fatal error was preceeded by a few WARNINGs which are shown below: Error extracting info/paths.json in \\stanwell.com\delivery\TradingAnalytics\PackageRepository\conda\external\win-64\bz2file-0.98-py36_0.tar.bz2: KeyError("filename 'info/paths.json' not found",) Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 306, in _read_index_tar paths_json = json.loads(t.extractfile('info/paths.json').read().decode('utf-8')) File "C:\Miniconda3\lib\tarfile.py", line 2073, in extractfile tarinfo = self.getmember(member) File "C:\Miniconda3\lib\tarfile.py", line 1749, in getmember raise KeyError("filename %r not found" % name) KeyError: "filename 'info/paths.json' not found" WARNING:conda_build.index:Error extracting info/paths.json in \\stanwell.com\delivery\TradingAnalytics\PackageRepository\conda\external\win-64\bz2file-0.98-py36_0.tar.bz2: KeyError("filename 'info/paths.json' not found",) Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 306, in _read_index_tar paths_json = json.loads(t.extractfile('info/paths.json').read().decode('utf-8')) File "C:\Miniconda3\lib\tarfile.py", line 2073, in extractfile tarinfo = self.getmember(member) File "C:\Miniconda3\lib\tarfile.py", line 1749, in getmember raise KeyError("filename %r not found" % name) KeyError: "filename 'info/paths.json' not found" Error extracting info/recipe/meta.yaml in \\stanwell.com\delivery\TradingAnalytics\PackageRepository\conda\external\win-64\bz2file-0.98-py36_0.tar.bz2: KeyError("filename 'info/recipe/meta.yaml' not found",) Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 313, in _read_index_tar t.extractfile('info/recipe/meta.yaml').read().decode('utf-8') File "C:\Miniconda3\lib\tarfile.py", line 2073, in extractfile tarinfo = self.getmember(member) File "C:\Miniconda3\lib\tarfile.py", line 1749, in getmember raise KeyError("filename %r not found" % name) KeyError: "filename 'info/recipe/meta.yaml' not found" WARNING:conda_build.index:Error extracting info/recipe/meta.yaml in \\stanwell.com\delivery\TradingAnalytics\PackageRepository\conda\external\win-64\bz2file-0.98-py36_0.tar.bz2: KeyError("filename 'info/recipe/meta.yaml' not found",) Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 313, in _read_index_tar t.extractfile('info/recipe/meta.yaml').read().decode('utf-8') File "C:\Miniconda3\lib\tarfile.py", line 2073, in extractfile tarinfo = self.getmember(member) File "C:\Miniconda3\lib\tarfile.py", line 1749, in getmember raise KeyError("filename %r not found" % name) KeyError: "filename 'info/recipe/meta.yaml' not found" Error extracting info/about.json in \\stanwell.com\delivery\TradingAnalytics\PackageRepository\conda\external\win-64\sqlite-3.13.0-vc14_0.tar.bz2: KeyError("filename 'info/about.json' not found",) Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 300, in _read_index_tar about_json = json.loads(t.extractfile('info/about.json').read().decode('utf-8')) File "C:\Miniconda3\lib\tarfile.py", line 2073, in extractfile tarinfo = self.getmember(member) File "C:\Miniconda3\lib\tarfile.py", line 1749, in getmember raise KeyError("filename %r not found" % name) KeyError: "filename 'info/about.json' not found" WARNING:conda_build.index:Error extracting info/about.json in \\stanwell.com\delivery\TradingAnalytics\PackageRepository\conda\external\win-64\sqlite-3.13.0-vc14_0.tar.bz2: KeyError("filename 'info/about.json' not found",) Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 300, in _read_index_tar about_json = json.loads(t.extractfile('info/about.json').read().decode('utf-8')) File "C:\Miniconda3\lib\tarfile.py", line 2073, in extractfile tarinfo = self.getmember(member) File "C:\Miniconda3\lib\tarfile.py", line 1749, in getmember raise KeyError("filename %r not found" % name) KeyError: "filename 'info/about.json' not found" — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
From @dhirschfeld on December 5, 2017 6:38
Great, thanks! In case its' useful (and since I've already done it) I monkey-patched encoder.py
to provide a bit more context:
TypeError: Object is not JSON serializable
type(o) = <class 'method'>
repr(o) = <bound method Environment.package_specs of <conda_build.environ.Environment object at 0x0000000006E460F0>>
From @dhirschfeld on December 5, 2017 6:39
conda 4.3.30 py36h7e176b0_0
conda-build 3.0.30 py36he296fd2_0
So all the
KeyError: "filename 'info/paths.json' not found"
messages are just fluff. I've got a PR I'm about to push to silence those.
However, for
File "C:\Miniconda3\lib\site-packages\conda_build\index.py", line 246, in update_subdir_index
json.dump(recipe, fo, indent=2, sort_keys=True)
I'm not seeing how we're possibly getting anything stuck in recipe
that's a problem :(
Wait, maybe I do.
recipe_text = t.extractfile('info/recipe/meta.yaml').read().decode('utf-8')
recipe_json = yaml.load(recipe_text)
Can you identify a specific meta.yaml file this might be getting hung up with? Yaml can get pretty crazy if you start using some of the more advanced features. Something might be sneaking in that way.
From @dhirschfeld on January 26, 2018 11:28
Will try to have a look this weekend...
From @eddy-ojb on January 30, 2018 20:15
I am getting the same error. Has there been any progress? I am new to this process. Can I just roll back a version to sort this out?
From @dhirschfeld on January 30, 2018 23:50
@eddy-ojb - what version of conda do you have (post the result of conda info
to your above message)
From @j-harts on March 12, 2018 13:54
I'm getting the same error too, with the mro-basics-3.4.3-0.tar.gz
and mro-base-3.4.3-0.tar.gz
files from the official R channel.
conda info
:
...
conda version : 4.4.11
conda-build version : 3.7.1
python version : 3.6.4.final.0
...
platform : win-64
...
Update. It seems that this is failing on or after the last file in a repository, above a certain number. The better-exceptions log is:
Traceback (most recent call last):
File "C:\Users\username\miniconda\Scripts\conda-index-script.py", line 10, in <module>
sys.exit(main())
| -> <function main at 0x0000000005C7DBF8>
-> <module 'sys' (built-in)>
File "C:\Users\username\miniconda\lib\site-packages\conda_build\cli\main_index.py", line 75, in main
return execute(sys.argv[1:])
| -> <module 'sys' (built-in)>
-> <function execute at 0x0000000005C7DB70>
File "C:\Users\username\miniconda\lib\site-packages\conda_build\cli\main_index.py", line 71, in execute
channel_name=args.channel_name)
File "C:\Users\username\miniconda\lib\site-packages\conda_build\api.py", line 385, in update_index
locking=config.locking, timeout=config.timeout, channel_name=channel_name)
File "C:\Users\username\miniconda\lib\site-packages\conda_build\index.py", line 147, in update_index
channel_name)
File "C:\Users\username\miniconda\lib\site-packages\conda_build\index.py", line 246, in update_subdir_index
json.dump(recipe, fo, indent=2, sort_keys=True)
| | -> <_io.TextIOWrapper name='R:\\Pricing\\Python_Tools\\conda_repositories\\r\\win-64\\.recipe.json' mode='w' encoding='cp1252'>
| -> {'r-3.4.3-mro343_0.tar.bz2': {'package': {'name': 'r', 'version': '3.4.3'}, 'build': {'merge_build_host': 'True', 'number': '0',...
-> <module 'json' from 'C:\\Users\\username\\miniconda\\lib\\json\\__init__.py'>
File "C:\Users\username\miniconda\lib\json\__init__.py", line 179, in dump
for chunk in iterable:
File "C:\Users\username\miniconda\lib\json\encoder.py", line 430, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
| | -> 0
| -> {'r-3.4.3-mro343_0.tar.bz2': {'package': {'name': 'r', 'version': '3.4.3'}, 'build':{'merge_build_host': 'True', 'number': '0',...
-> <function _make_iterencode.<locals>._iterencode_dict at 0x00000000101C8A60>
File "C:\Users\username\miniconda\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
-> <generator object _make_iterencode.<locals>._iterencode_dict at 0x000000001132C938>
File "C:\Users\username\miniconda\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
-> <generator object _make_iterencode.<locals>._iterencode_dict at 0x000000001132C830>
File "C:\Users\username\miniconda\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
-> <generator object _make_iterencode.<locals>._iterencode at 0x000000001132C8E0>
File "C:\Users\username\miniconda\lib\json\encoder.py", line 437, in _iterencode
o = _default(o)
| | -> <bound method Environment.package_specs of <conda_build.environ.Environment object at 0x0000000006C459E8>>
| -> <bound method JSONEncoder.default of <json.encoder.JSONEncoder object at 0x0000000005E82BE0>>
-> <bound method Environment.package_specs of <conda_build.environ.Environment object at 0x0000000006C459E8>>
File "C:\Users\username\miniconda\lib\json\encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'method' is not JSON serializable
Moved this to the correct repo.
At one point, I tried to reproduce the original issue, as reported by @dhirschfeld. It's been a while, but as I recall, I wasn't able to reproduce it, and it was clear to me where the actual issue was.
I haven't yet tried reproducing the issue reported by @j-harts.
One thing you might try if you have a problem here is removing all the directories in the subdirs that start with .
. E.g.
find /opt/conda/conda-bld -name \.\* -type d [-delete]
I haven't come back to this as I think it may be fixed in newer versions - I haven't seen it since upgrading long ago
Great, closing for now. Happy to reopen if anyone wants.
I can reproduce the error by:
conda version : 4.4.11
conda-build version : 3.7.1
python version : 3.6.4.final.0
The error presents itself after all the packages have been listed as Updating: package.tar.gz
and stops the repodata files from being created. However we do see some new hidden files
.icons
.about.json
.index.json
.paths.json
.recipe.json
The .recipe.json
file ends prematurely with
"r-acepack-1.4.1-r3.3.2_0.tar.bz2": {
"about": {
"license": "MIT + file LICENSE",
"license_family": "MIT",
"summary": "Two nonparametric methods for multiple regression transform selection are provided. The first, Alternative Conditional Expectations (ACE), is an algorithm to find the fixed point of maximal correlation, i.e. it finds a set of transformed response variables that maximizes R^2 using smoothing functions [see Breiman, L., and J.H. Friedman. 1985. \"Estimating Optimal Transformations for Multiple Regression and Correlation\". Journal of the American Statistical Association. 80:580-598. <doi:10.1080/01621459.1985.10478157>]. Also included is the Additivity Variance Stabilization (AVAS) method which works better than ACE when correlation is low [see Tibshirani, R.. 1986. \"Estimating Transformations for Regression via Additivity and Variance Stabilization\". Journal of the American Statistical Association. 83:394-405. <doi:10.1080/01621459.1988.10478610>]. A good introduction to these two methods is in chapter 16 of Frank Harrel's \"Regression Modeling Strategies\" in the Springer Series in Statistics."
},
"build": {
"rpaths": [
"lib/R/lib/",
"lib/"
],
"string": "r3.3.2_0"
},
"package": {
"name": "r-acepack",
"version": "1.4.1"
},
"requirements": {
"build":
Is there any chance we can reopen?
Sure, thanks for the further info.
Just deleted the offending .recipe.json
but kept the rest and rerunning conda index worked. That's a workaround for now, although not ideal.
That's not a workaround because .recipe.json
is actually the result of conda index
work.
when you delete it, it is not recreated automatically, and when you try conda index -f
the error is raised again.
My "workaround" was to remove the package, that caused error (the last seen in .recipe.json) , from the repo.
And my way to reproduce error is:
mkdir testdir
curl https://anaconda.org/conda-forge/libiconv/1.14/download/win-64/libiconv-1.14-vc14_4.tar.bz2 -L --output ./testdir/libiconv-1.14-vc14_4.tar.bz2
conda index ./testdir
If you need to add "problem" packages, you can temporarily downgrade conda-build
conda install --force "conda-build=3.0.9"
conda index <dirname>
conda install --force conda-build
As I can see, error was introduced somewhere between versions 3.0.9 and 3.0.31
I also encountered this issue while indexing a directory of packages that included the package libiconv-1.14-vc14_4.tar.bz2
mentioned by @elfwired. That package's meta.yaml
file contains the following data that cannot be serialized by the JSON encoder:
requirements:
build: !!python/object/apply:builtins.getattr
- !!python/object:conda_build.environ.Environment
_meta: C:\Miniconda35-x64\conda-bld\recipe_1481573594901\_b_env\conda-meta
_packages: {}
path: C:\Miniconda35-x64\conda-bld\recipe_1481573594901\_b_env
- package_specs
The meta.yaml
file in the r-acepack-1.4.1-r3.3.2_0.tar.bz2
package mentioned by @j-hartshorn contains similar content. The problem that led to that content seems to have been resolved by #1589.
The problem here, in which conda index
fails for such meta.yaml
files, may have appeared in conda-build v. 3.0.28 from, I believe, 644472af218a2b9382e5d0170cb76d539972ec33, where the code began indexing the recipe data.
A sufficient fix might be to modify index._read_index_tar
by replacing yaml.load
with yaml.safe_load
and yaml.scanner.ScannerError
with yaml.error.MarkedYAMLError
(a base class of both ScannerError
and the ConstructorError
raised by safe_load
). That worked in my test using libiconv-1.14-vc14_4.tar.bz2
.
Has there been any further updates to this? I have conda-build version 3.10.9 and I get a similar error (see below). The previous post mention version 3.0.*. How does 3.10.* compare to 3.0.*? I would expect those versions to be quite different but it has only been 25 days since @stanwest's last post mentioning
The problem here, in which conda index fails for such meta.yaml files, may have appeared in conda-build v. 3.0.28 from, I believe, 644472a, where the code began indexing the recipe data.
I can verify I do have the libiconv
package in the folder I am indexing but a different version, libiconv-1.15-h1df5818_7.tar.bz2
. I'm not sure if this difference matters.
I found that after reverting to version 3.0.27 (conda install --force "conda-build=3.0.27
) the index process completed without errors.
Here is the error I get.
Traceback (most recent call last):
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\Scripts\conda-index-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\site-packages\conda_build\cli\main_index.py", line 75, in main
return execute(sys.argv[1:])
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\site-packages\conda_build\cli\main_index.py", line 71, in execute
channel_name=args.channel_name)
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\site-packages\conda_build\api.py", line 386, in update_index
locking=config.locking, timeout=config.timeout, channel_name=channel_name)
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\site-packages\conda_build\index.py", line 147, in update_index
channel_name)
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\site-packages\conda_build\index.py", line 246, in update_subdir_index
json.dump(recipe, fo, indent=2, sort_keys=True)
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\__init__.py", line 179, in dump
for chunk in iterable:
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\encoder.py", line 430, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\encoder.py", line 437, in _iterencode
o = _default(o)
File "C:\Users\steven.howell\AppData\Local\Continuum\anaconda3\envs\r4ds\envs\repo\lib\json\encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'method' is not JSON serializable
I am also getting an error in the latest version of conda-build 3.10.9-. Is this still not fixed?
Traceback (most recent call last):
File "C:\Users\TS127TT\AppData\Local\Continuum\anaconda3\Scripts\conda-index-script.py", line 10, in
Once sucessfully indexed using an older version of conda-build, I then install a package through the channel and get the following error:
As of conda 4.3, a valid channel must contain a noarch/repodata.json
and
associated noarch/repodata.json.bz2
file, even if noarch/repodata.json
is
empty. please request that the channel administrator create
noarch/repodata.json
and associated noarch/repodata.json.bz2
files.
$ mkdir noarch
$ echo '{}' > noarch/repodata.json
$ bzip2 -k noarch/repodata.json
You will need to adjust your conda configuration to proceed.
Use conda config --show channels
to view your configuration's current state.
Further configuration help can be found at https://conda.io/docs/config.html.
Even if these specified files exist, I get the error - so the error message is meaningless.
try a conda index
in the noarch
directory rather than trying to create the files manually
I believe that this issue has been resolved and may be closed.
As I understand the problem, in index._read_index_tar
, yaml.load
unsafely loaded meta.yaml
files containing complex Python tags and returned recipe structures containing, for example, the Python method object conda_build.environ.Environment.package_specs
. Subsequently, in index.update_subdir_index
, json.dump
raised TypeError: Object of type 'method' is not JSON serializable
.
Commit 1347f3d, which is in #3091 and v. 3.14.0, resolved the problem in index._cache_recipe
by using yaml.safe_load
, catching its exception, and substituting {}
for the recipe.
Hi there, thank you for your contribution!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.
If you would like this issue to remain open please:
NOTE: If this issue was closed prematurely, please leave a comment.
Thanks!
From @dhirschfeld on December 5, 2017 6:20
I'm trying to mirror packages in an internal repo for use in an offline install. This has worked for years but today when trying to create a clean repository the
conda index
command failed with the below error:This final fatal error was preceeded by a few WARNINGs which are shown below:
Copied from original issue: conda/conda#6397