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

James Valleroy jvalleroy at mailbox.org
Thu Apr 4 15:13:07 BST 2024


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-javascript-devel/attachments/20240404/a93dbc46/attachment.sig>


More information about the Pkg-javascript-devel mailing list