Bug#1058552: [Pkg-javascript-devel] Bug#1058552: science.js: FTBFS: SyntaxError: Error parsing /<>/package.json: Unexpected end of JSON input

2024-04-05 Thread James Valleroy

On Thu, 04 Apr 2024 19:01:58 +0200 Jonas Smedegaard  wrote:

Quoting James Valleroy (2024-04-04 16:13:07)
> On 3/28/24 4:08 AM, Petter Reinholdtsen wrote:
> > [James Valleroy 2024-02-12]
> >> Here is a patch that fixes the build:
> > 
> > Btw, did you mean TEMPFILE=$(shell mktemp) to get a random temp file

> > name?
> > 
> 
> I'm not sure. It may also work, but there is a difference in when a 
> shell command runs. Some people recommend not to use shell in a 
> makefile: https://stackoverflow.com/a/76121578


Each make target (i.e. each line indended by a tab) is executed within a
shell.  The point in the SO answer you reference is that calling the
make function $(shell ...) *inside* a make target effectively spawns a
shell within another shell, and *that* you rarely really want.

What Petter is talking about above is that "TEMPFILE=mktemp", because it
is a make target (i.e. on a TAB-indented line) is passed to a shell,
which will *not* set TEMPFILE to the output of the shell command mktemp,
but simply set TEMPFILE to the _string_ "mktemp" which is unlikely that
you want.


I see, thanks for pointing that out. I think there isn't a need to use 
mktemp here, so the patch can be simplified to this:



diff --git a/Makefile b/Makefile
index c9e03c2..f5a954b 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,8 @@ install:

 package.json: src/package.js
@rm -f $@
-   node src/package.js > $@
+   node src/package.js > package.json.temp
+   mv package.json.temp $@
@chmod a-w $@

 clean:


OpenPGP_signature.asc
Description: OpenPGP digital signature


Bug#1058552: [Pkg-javascript-devel] Bug#1058552: science.js: FTBFS: SyntaxError: Error parsing /<>/package.json: Unexpected end of JSON input

2024-04-04 Thread Jonas Smedegaard
Quoting James Valleroy (2024-04-04 16:13:07)
> On 3/28/24 4:08 AM, Petter Reinholdtsen wrote:
> > [James Valleroy 2024-02-12]
> >> Here is a patch that fixes the build:
> > 
> > Thank you.  Can you explain why changing the output from package.json to
> > mktemp and then moving the result to package.json will solve the build
> > problem?  I fail to understand how this could change anything.
> 
> The makefile receipe uses node to produce the content that will be 
> written to package.json. It seems that node is also trying to read in 
> and parse the contents of package.json. Apparently, writing the file is 
> not an atomic operation, so node is reading it before the write 
> operation has completed. So it reads some partially-written package.json 
> file, which is not yet valid JSON, and produces an error when trying to 
> parse it.
> 
> I don't know enough about node to say why it does this (reading in 
> package.json after it has started running the src/package.js script).
> 
> > Btw, did you mean TEMPFILE=$(shell mktemp) to get a random temp file
> > name?
> > 
> 
> I'm not sure. It may also work, but there is a difference in when a 
> shell command runs. Some people recommend not to use shell in a 
> makefile: https://stackoverflow.com/a/76121578

Each make target (i.e. each line indended by a tab) is executed within a
shell.  The point in the SO answer you reference is that calling the
make function $(shell ...) *inside* a make target effectively spawns a
shell within another shell, and *that* you rarely really want.

What Petter is talking about above is that "TEMPFILE=mktemp", because it
is a make target (i.e. on a TAB-indented line) is passed to a shell,
which will *not* set TEMPFILE to the output of the shell command mktemp,
but simply set TEMPFILE to the _string_ "mktemp" which is unlikely that
you want.


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/
 * Sponsorship: https://ko-fi.com/drjones

 [x] quote me freely  [ ] ask before reusing  [ ] keep private

signature.asc
Description: signature


Bug#1058552: science.js: FTBFS: SyntaxError: Error parsing /<>/package.json: Unexpected end of JSON input

2024-04-04 Thread James Valleroy

On 3/28/24 4:08 AM, Petter Reinholdtsen wrote:

[James Valleroy 2024-02-12]

Here is a patch that fixes the build:


Thank you.  Can you explain why changing the output from package.json to
mktemp and then moving the result to package.json will solve the build
problem?  I fail to understand how this could change anything.


The makefile receipe uses node to produce the content that will be 
written to package.json. It seems that node is also trying to read in 
and parse the contents of package.json. Apparently, writing the file is 
not an atomic operation, so node is reading it before the write 
operation has completed. So it reads some partially-written package.json 
file, which is not yet valid JSON, and produces an error when trying to 
parse it.


I don't know enough about node to say why it does this (reading in 
package.json after it has started running the src/package.js script).



Btw, did you mean TEMPFILE=$(shell mktemp) to get a random temp file
name?



I'm not sure. It may also work, but there is a difference in when a 
shell command runs. Some people recommend not to use shell in a 
makefile: https://stackoverflow.com/a/76121578


OpenPGP_signature.asc
Description: OpenPGP digital signature


Bug#1058552: science.js: FTBFS: SyntaxError: Error parsing /<>/package.json: Unexpected end of JSON input

2024-03-28 Thread Petter Reinholdtsen
[James Valleroy 2024-02-12]
> Here is a patch that fixes the build:

Thank you.  Can you explain why changing the output from package.json to
mktemp and then moving the result to package.json will solve the build
problem?  I fail to understand how this could change anything.

Btw, did you mean TEMPFILE=$(shell mktemp) to get a random temp file
name?

-- 
Happy hacking
Petter Reinholdtsen



Bug#1058552: science.js: FTBFS: SyntaxError: Error parsing /<>/package.json: Unexpected end of JSON input

2024-02-12 Thread James Valleroy

tags 1058552 patch
thanks

Here is a patch that fixes the build:

From: James Valleroy 
Date: Sun, 11 Feb 2024 07:40:16 -0500
Subject: Use a temp file for package.json contents

---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index c9e03c2..4cbfec9 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,9 @@ install:

 package.json: src/package.js
@rm -f $@
-   node src/package.js > $@
+   TEMPFILE=mktemp
+   node src/package.js > "$TEMPFILE"
+   mv "$TEMPFILE" $@
@chmod a-w $@

 clean:


OpenPGP_signature.asc
Description: OpenPGP digital signature


Bug#1058552: science.js: FTBFS: SyntaxError: Error parsing /<>/package.json: Unexpected end of JSON input

2023-12-12 Thread Lucas Nussbaum
Source: science.js
Version: 1.9.3+dfsg-3
Severity: serious
Justification: FTBFS
Tags: trixie sid ftbfs
User: lu...@debian.org
Usertags: ftbfs-20231212 ftbfs-trixie

Hi,

During a rebuild of all packages in sid, your package failed to build
on amd64.


Relevant part (hopefully):
> make[2]: Entering directory '/<>'
> cat src/core/core.js src/core/ascending.js src/core/constants.js 
> src/core/expm1.js src/core/functor.js src/core/hypot.js src/core/quadratic.js 
> src/core/zeroes.js >> science.core.js
> cat src/lin/lin.js src/lin/decompose.js src/lin/cross.js src/lin/dot.js 
> src/lin/length.js src/lin/normalize.js src/lin/determinant.js 
> src/lin/gaussjordan.js src/lin/inverse.js src/lin/multiply.js 
> src/lin/transpose.js src/lin/tridag.js >> science.lin.js
> cat src/stats/stats.js src/stats/bandwidth.js src/stats/distance.js 
> src/stats/erf.js src/stats/phi.js src/stats/kernel.js src/stats/kde.js 
> src/stats/kmeans.js src/stats/hcluster.js src/stats/iqr.js src/stats/loess.js 
> src/stats/mean.js src/stats/median.js src/stats/mode.js 
> src/stats/quantiles.js src/stats/variance.js src/stats/distribution.js 
> src/stats/distribution/gaussian.js >> science.stats.js
> cat science.core.js science.lin.js science.stats.js >> science.v1.js
> uglifyjs < science.v1.js > science.v1.min.js
> node src/package.js > package.json
> node:internal/modules/package_json_reader:92
> throw error;
> ^
> 
> SyntaxError: Error parsing /<>/package.json: Unexpected end of 
> JSON input
> at parse ()
> at read (node:internal/modules/package_json_reader:79:16)
> at readPackage (node:internal/modules/package_json_reader:140:10)
> at readPackageScope (node:internal/modules/package_json_reader:157:19)
> at shouldUseESMLoader (node:internal/modules/run_main:77:15)
> at Function.executeUserEntryPoint [as runMain] 
> (node:internal/modules/run_main:122:24)
> at node:internal/main/run_main_module:28:49 {
>   path: '/<>/package.json'
> }
> 
> Node.js v18.19.0
> make[2]: *** [Makefile:80: package.json] Error 1


The full build log is available from:
http://qa-logs.debian.net/2023/12/12/science.js_1.9.3+dfsg-3_unstable.log

All bugs filed during this archive rebuild are listed at:
https://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=ftbfs-20231212;users=lu...@debian.org
or:
https://udd.debian.org/bugs/?release=na=ign=7=7=only=ftbfs-20231212=lu...@debian.org=1=1=1=1#results

A list of current common problems and possible solutions is available at
http://wiki.debian.org/qa.debian.org/FTBFS . You're welcome to contribute!

If you reassign this bug to another package, please mark it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects

If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.