Bug 337446

Summary: malformed JSON string
Product: [Developer tools] kdesrc-build Reporter: Unknown <null>
Component: generalAssignee: Michael Pyne <mpyne>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 1.16
Sentry Crash Report:

Description Unknown 2014-07-14 17:09:58 UTC
I just get the software, make a first start as:
$ ./kdesrc-build --pretend
        Would have created /home/guy-kde/src/5
 * Downloading projects.kde.org project database (will not be saved due to pretend mode)...
        Cloning kde-build-metadata
Encountered an error in the execution of the script.
The error reported was malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Updater/KDEProjectMetadata.pm line 62.
 at /usr/share/perl5/core_perl/JSON/PP.pm line 1213.
        JSON::PP::decode_error("malformed JSON string, neither array, object, number, string "...) called at /usr/share/perl5/core_perl/JSON/PP.pm line 644
        JSON::PP::PP_decode_json(JSON::PP=HASH(0x2e8da18), undef, 0) called at /usr/share/perl5/core_perl/JSON/PP.pm line 148
        JSON::PP::decode(JSON::PP=HASH(0x2e8da18)) called at /usr/share/perl5/core_perl/JSON/PP.pm line 110
        JSON::PP::decode_json() called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Updater/KDEProjectMetadata.pm line 62
        ksb::Updater::KDEProjectMetadata::logicalModuleGroups(ksb::Updater::KDEProjectMetadata=HASH(0x2ce6408)) called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/BuildContext.pm line 989
        ksb::BuildContext::moduleBranchGroupResolver(ksb::BuildContext=HASH(0x169fd70)) called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Application.pm line 729
        ksb::Application::runAllModulePhases(ksb::Application=HASH(0x27a5858)) called at ./kdesrc-build line 233
        eval {...} called at ./kdesrc-build line 219

Reproducible: Always

Steps to Reproduce:
just start
Comment 1 Michael Pyne 2014-07-16 03:32:48 UTC
I think this is a valid bug (as you can probably imagine I don't run kdesrc-build for the first time too often). I'm still trying to think of the best way to fix.

As a workaround you might do something like:

kdesrc-build --src-only extra-cmake-modules

to have kdesrc-build download the kde-build-metadata module needed for the rest to work, and then "kdesrc-build --pretend" should work.
Comment 2 Michael Pyne 2014-07-16 05:09:19 UTC
Git commit 6911da5c8713c3e33e8e43c6707a2c871bf79375 by Michael Pyne.
Committed on 16/07/2014 at 05:00.
Pushed by mpyne into branch 'master'.

Improve first-run behavior with build metadata.

This commit makes the kde-build-metadata module a requirement instead of
an option, since the vast majority of runs will require this module now.

Additionally the --metadata-only option is added and documented to allow
for downloading the kde-build-metadata module alone (and make the
--pretend option work afterwards), and kdesrc-build recommends using it
if you run with --pretend and without metadata.

This should hopefully make the first-run use case easier for users.
FIXED-IN:1.16

M  +29   -4    doc/index.docbook
M  +14   -0    doc/man-kdesrc-build.1.docbook
M  +49   -23   modules/ksb/Application.pm

http://commits.kde.org/kdesrc-build/6911da5c8713c3e33e8e43c6707a2c871bf79375
Comment 3 Unknown 2014-07-16 12:45:14 UTC
(In reply to Michael Pyne from comment #1)
> I think this is a valid bug (as you can probably imagine I don't run
> kdesrc-build for the first time too often). I'm still trying to think of the
> best way to fix.
> 
> As a workaround you might do something like:
> 
> kdesrc-build --src-only extra-cmake-modules
> 
> to have kdesrc-build download the kde-build-metadata module needed for the
> rest to work, and then "kdesrc-build --pretend" should work.

The workaround works pretty well. Thanks.
Comment 4 Unknown 2014-07-16 14:17:28 UTC
I get the new version: 6911da5c8713c3e33e8e43c6707a2c871bf79375 2014-07-16 07:00:55
but it doesn't run as you said:
a new first run, with all new. Sorry!

~/kdesrc/kdesrc-build/kdesrc-build --pretend --debug
 * Using included sample configuration.                   RIGHT: I(guy) don't have any configuration file, but the sample one produces errors I(beginner) don't anderstand

Introducing metadata module into the build
        Cloning kde-build-metadata
log_command(): Module kde-build-metadata, Command: git clone -- kde:kde-build-metadata /home/guy-kde/kdesrc/kde-build-metadata
        Would have run 'git' 'clone' '--' 'kde:kde-build-metadata' '/home/guy-kde/kdesrc/kde-build-metadata'
        cd /home/guy-kde/kdesrc/kde-build-metadata

 * Downloading projects.kde.org project database (will not be saved due to pretend mode)...
Using proxy as determined by environment
Downloading /tmp/kde_projectsdOcEVz.xml from http://projects.kde.org/kde_projects.xml
--- Ignoring matched active module nepomuk-widgets in module set <module-set at line 252>
--- Ignoring matched active module nepomuk-core in module set <module-set at line 252>
--- Ignoring matched active module nepomuk-widgets in module set <module-set at line 252>
--- Ignoring matched active module nepomuk-core in module set <module-set at line 252>
--- Ignoring matched active module ffmpegthumbs in module set <module-set at line 300>
--- Ignoring matched active module ffmpegthumbs in module set <module-set at line 300>
Filtering out module phases.
Set context ignore list to 
Encountered an error in the execution of the script.
The error reported was malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Updater/KDEProjectMetadata.pm line 62.
 at /usr/share/perl5/core_perl/JSON/PP.pm line 1213.
        JSON::PP::decode_error("malformed JSON string, neither array, object, number, string "...) called at /usr/share/perl5/core_perl/JSON/PP.pm line 644
        JSON::PP::PP_decode_json(JSON::PP=HASH(0x3154570), undef, 0) called at /usr/share/perl5/core_perl/JSON/PP.pm line 148
        JSON::PP::decode(JSON::PP=HASH(0x3154570)) called at /usr/share/perl5/core_perl/JSON/PP.pm line 110
        JSON::PP::decode_json() called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Updater/KDEProjectMetadata.pm line 62
        ksb::Updater::KDEProjectMetadata::logicalModuleGroups(ksb::Updater::KDEProjectMetadata=HASH(0x298bf30)) called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/BuildContext.pm line 989
        ksb::BuildContext::moduleBranchGroupResolver(ksb::BuildContext=HASH(0x1972d78)) called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Application.pm line 756
        ksb::Application::runAllModulePhases(ksb::Application=HASH(0x2a79348)) called at /home/guy-kde/kdesrc/kdesrc-build/kdesrc-build line 233
        eval {...} called at /home/guy-kde/kdesrc/kdesrc-build/kdesrc-build line 219
Comment 5 Unknown 2014-07-16 14:24:14 UTC
now I have a configuration file, but nobody(even with --debug) says me, which file is used!
And the bug is still present:
~/kdesrc/kdesrc-build/kdesrc-build --pretend --debug
Introducing metadata module into the build
        Cloning kde-build-metadata
log_command(): Module kde-build-metadata, Command: git clone -- kde:kde-build-metadata /home/guy-kde/src/5/kde-build-metadata
        Would have run 'git' 'clone' '--' 'kde:kde-build-metadata' '/home/guy-kde/src/5/kde-build-metadata'
        cd /home/guy-kde/src/5/kde-build-metadata

 * Downloading projects.kde.org project database (will not be saved due to pretend mode)...
Using proxy as determined by environment
Downloading /tmp/kde_projectsbrksqx.xml from http://projects.kde.org/kde_projects.xml
--- Ignoring matched active module nepomuk-widgets in module set <module-set at line 256>
--- Ignoring matched active module nepomuk-core in module set <module-set at line 256>
--- Ignoring matched active module nepomuk-widgets in module set <module-set at line 256>
--- Ignoring matched active module nepomuk-core in module set <module-set at line 256>
--- Ignoring matched active module ffmpegthumbs in module set <module-set at line 304>
--- Ignoring matched active module ffmpegthumbs in module set <module-set at line 304>
Filtering out module phases.
Set context ignore list to 
Encountered an error in the execution of the script.
The error reported was malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Updater/KDEProjectMetadata.pm line 62.
 at /usr/share/perl5/core_perl/JSON/PP.pm line 1213.
        JSON::PP::decode_error("malformed JSON string, neither array, object, number, string "...) called at /usr/share/perl5/core_perl/JSON/PP.pm line 644
        JSON::PP::PP_decode_json(JSON::PP=HASH(0x3b484f0), undef, 0) called at /usr/share/perl5/core_perl/JSON/PP.pm line 148
        JSON::PP::decode(JSON::PP=HASH(0x3b484f0)) called at /usr/share/perl5/core_perl/JSON/PP.pm line 110
        JSON::PP::decode_json() called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Updater/KDEProjectMetadata.pm line 62
        ksb::Updater::KDEProjectMetadata::logicalModuleGroups(ksb::Updater::KDEProjectMetadata=HASH(0x34f8d38)) called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/BuildContext.pm line 989
        ksb::BuildContext::moduleBranchGroupResolver(ksb::BuildContext=HASH(0x24ded78)) called at /home/guy-kde/kdesrc/kdesrc-build/modules/ksb/Application.pm line 756
        ksb::Application::runAllModulePhases(ksb::Application=HASH(0x35e4f08)) called at /home/guy-kde/kdesrc/kdesrc-build/kdesrc-build line 233
        eval {...} called at /home/guy-kde/kdesrc/kdesrc-build/kdesrc-build line 219
Comment 6 Unknown 2014-07-16 14:33:54 UTC
using the workaround (above) is not better:
$ ~/kdesrc/kdesrc-build/kdesrc-build --src-only extra-cmake-modules --debug
 * Using included sample configuration.
Introducing metadata module into the build
        Cloning kde-build-metadata
log_command(): Module kde-build-metadata, Command: git clone -- kde:kde-build-metadata /home/guy-kde/kdesrc/kde-build-metadata
# kdesrc-build running: 'git' 'clone' '--' 'kde:kde-build-metadata' '/home/guy-kde/kdesrc/kde-build-metadata'
# from directory: /home/guy-kde/src/5
Cloning into '/home/guy-kde/kdesrc/kde-build-metadata'...
        cd /home/guy-kde/kdesrc/kde-build-metadata

Slurping 'git' '--git-dir' '/home/guy-kde/kdesrc/kde-build-metadata/.git' 'ls-files'
 * Downloading projects.kde.org project database...
Using proxy as determined by environment
Downloading /home/guy-kde/kdesrc/kde_projects.xml from http://projects.kde.org/kde_projects.xml
No command-line filter seems to be present.
 *: Error No such file or directory while creating lock file (is ~/kdesrc/kdesrc-build available?)
 *: Continuing the script for now...
...
YES, the directory is available:
ls -ld ~/kdesrc/kdesrc-build
drwxr-xr-x 5 guy-kde users 4096 Jul 16 16:10 /home/guy-kde/kdesrc/kdesrc-build
Comment 7 Unknown 2014-07-16 14:41:23 UTC
sorry: The comment 6 is not correct: please forget it.
Comment 8 Michael Pyne 2014-07-17 03:23:09 UTC
Well, what's *supposed* to happen is that if you run "kdesrc-build --pretend" as step 1, you get a message like:

kdesrc-build encountered an exceptional error condition: Runtime Error: 
        Can't use --pretend without having metadata
                available, and can't download it in pretend mode. Try running
                "kdesrc-build --metadata-only" first and try again.
        Can't continue, so stopping now.

(which is mostly a stopgap, the "better" thing is to download to a temp directory similar to what we do for kde_projects.xml, but that's harder to code in). But in essence, your step 1 *should* be "kdesrc-build --metadata-only", since using the --pretend flag is supposed to mean that kdesrc-build doesn't take any permanent action. After that "kdesrc-build --pretend" would work.

Maybe I should change that and have --pretend permanently store the build metadata it needs as a special case...

It's possible that using the included sample-rc file is throwing off the check I inserted (I checked again here and it works, but I have a custom kdesrc-buildrc file to simulate the "first run" situation, I will need to test again with the sample kdesrc-buildrc).
Comment 9 Unknown 2014-07-17 15:41:36 UTC
The two commands:
  kdesrc-build --metadata-only
  kdesrc-build --pretend
 work pretty well.
A beginner should use them in this way.
Could you make a notice in the description?

One more point:
in the file kdesrc-build at line 4, I can read:
  ... in the file ~/.kdesrc-buildrc

This is not exact, as David said to me. The script reads first the file
  ./kdesrc-buildrc
if present on the same directory I started the command. A very nice feature.
So let "debug" tell me which configuration file I have opened.

If a sample kdesrc-buildrc is present, it will be used. mmmh! 
If any of the directories are not set correctly, the script works... and works.
I think, it should stop soon.
Comment 10 Unknown 2014-07-17 15:47:22 UTC
At the end of "pretend" one get some lines:
Message is FAILED TO UPDATE
        for 
Message is FAILED TO BUILD
        for 
Message is FAILED TO INSTALL
        for

I think, if nothing is to tell, don't tell anything.
Could you make a test of "message is empty"?
Comment 11 Michael Pyne 2014-08-08 02:39:51 UTC
Hi Guy,

I've updated the comment to be accurate with regard to the location of the configuration file.

I've also configured kdesrc-build to fail if the user doesn't have a configuration instead of using kdesrc-buildrc-sample, as you recommended.

As far as the empty debug output:
> Message is FAILED TO UPDATE
>         for 
> Message is FAILED TO BUILD
>         for 
> Message is FAILED TO INSTALL
>         for

I don't intend to make changes as using --debug should be pretty rare (it's to help me debug the script, not for the user per se) and it's easy enough to ignore.

I'll continue working on improving the first-run experience as I accumulate time.
Comment 12 Unknown 2014-08-08 13:09:07 UTC
Hello Michael!

On Friday, August 08, 2014 02:39:51 AM you wrote:
> https://bugs.kde.org/show_bug.cgi?id=337446
> 
> Michael Pyne <mpyne@kde.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
> Resolution|---                         |FIXED
>              Status|REOPENED                    |RESOLVED
> 
> --- Comment #11 from Michael Pyne <mpyne@kde.org> ---
> Hi Guy,
> 
> I've updated the comment to be accurate with regard to the location of the
> configuration file.
Fine.
I'll continue to test it... until the next bug!

Thanks for helping
Comment 13 Michael Pyne 2024-05-10 09:16:48 UTC
Git commit fab78b389048faff2db425e3e942da01403c74c0 by Michael Pyne.
Committed on 16/07/2014 at 05:00.
Pushed by ashark into branch 'docbook_historied_per_file'.

Improve first-run behavior with build metadata.

This commit makes the kde-build-metadata module a requirement instead of
an option, since the vast majority of runs will require this module now.

Additionally the --metadata-only option is added and documented to allow
for downloading the kde-build-metadata module alone (and make the
--pretend option work afterwards), and kdesrc-build recommends using it
if you run with --pretend and without metadata.

This should hopefully make the first-run use case easier for users.
FIXED-IN:1.16

Original commit: 6911da5c
https://invent.kde.org/sdk/kdesrc-build/-/commit/6911da5c8713c3e33e8e43c6707a2c871bf79375

M  +24   -3    doc/cmdline/supported-cmdline-params.docbook
M  +5    -1    doc/features/features-overview.docbook

https://invent.kde.org/sdk/kdesrc-build/-/commit/fab78b389048faff2db425e3e942da01403c74c0