Bug 1547897 - Useless error message: not a valid spec file: can't parse specfile
Summary: Useless error message: not a valid spec file: can't parse specfile
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1560291 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-22 08:51 UTC by Richard W.M. Jones
Modified: 2019-01-14 12:05 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-06-28 08:35:12 UTC


Attachments (Terms of Use)

Description Richard W.M. Jones 2018-02-22 08:51:26 UTC
Description of problem:

This error message is completely useless:

# dnf builddep /home/build/rpmbuild/SPECS/systemd.spec 
Last metadata expiration check: 9:40:09 ago on Wed 21 Feb 2018 15:32:36 UTC.
Failed to open: '/home/build/rpmbuild/SPECS/systemd.spec', not a valid spec file: can't parse specfile

It should at the very least tell us something about the error,
even the line number would be of some use.

BTW the exact same spec file on the exact same machine can be
parsed fine by rpmbuild, so it's not even a problem with the file.

Version-Release number of selected component (if applicable):

dnf-2.7.5-8.fc28.noarch

How reproducible:

100%

Steps to Reproduce:
1. See above.

Comment 1 Marek Blaha 2018-02-26 06:05:32 UTC
Please, can you provide this failing spec file?

Comment 2 Richard W.M. Jones 2018-02-26 08:23:21 UTC
The spec file isn't important.  It's only failing because a macro
somewhere (it's hard to tell where) isn't being expanded.

You can reproduce the bug with any bogus specfile, eg:

$ echo -e '\n\n\n\n\n\n' > foo.spec
$ sudo dnf builddep foo.spec
Last metadata expiration check: 0:03:28 ago on Mon 26 Feb 2018 08:19:08 GMT.
Failed to open: 'foo.spec', not a valid spec file: can't parse specfile

Comment 3 Marek Blaha 2018-03-28 06:09:41 UTC
The spec file parsing is done via rpm.spec("the file"). And this function does not produce any more detailed information on why it failed to parse the spec file.

I'd like to ask rpm team: is there another (more verbose / more benevolent to spec file errors) way how to get build requirements from the spec file in python?

Comment 4 Panu Matilainen 2018-03-28 06:47:28 UTC
Dnf is overriding rpm default logging level / redirecting it someplace (sorry I forget the details). The log will tell you the details - this is what it looks like by default:

[pmatilai@sopuli ~]$ python -c 'import rpm; s = rpm.spec("foo.spec")'
error: Name field must be present in package: (main package)
error: Version field must be present in package: (main package)
error: Release field must be present in package: (main package)
error: Summary field must be present in package: (main package)
error: License field must be present in package: (main package)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: can't parse specfile

There was the other similar bug about systemd.spec, which also becomes entirely obvious when the log messages come through:
[pmatilai@sopuli SPECS]$ python -c 'import rpm; s = rpm.spec("systemd.spec")'
error: Unable to open /srv/work/rpmbuild/SOURCES/triggers.systemd: No such file or directory
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: can't parse specfile

Back to dnf.

Comment 5 Marek Blaha 2018-03-28 07:46:44 UTC
Thanks Panu. The log is supposed to be in /var/log/dnf.rpm.log. But it looks like builddep plugin is not logging anything there. I'll have to look into that.

Comment 6 Panu Matilainen 2018-03-28 09:42:37 UTC
*** Bug 1560291 has been marked as a duplicate of this bug. ***

Comment 7 Marek Blaha 2018-04-06 12:08:24 UTC
PR https://github.com/rpm-software-management/dnf-plugins-core/pull/254 to redirect rpm library error to /var/log/dnf.rpm.log

Comment 8 Jaroslav Mracek 2018-06-28 08:35:12 UTC
The issue is solved by dnf-plugins-core-3.0.1-1 that was released into rawhide.

Comment 9 Panu Matilainen 2019-01-14 12:05:28 UTC
*** Bug 1663619 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.