marguerite / nodejs-packaging

nodejs packaging helpers and utilities for openSUSE
MIT License
5 stars 2 forks source link

JSON parsing fails if there is UTF-8 chars #1

Closed illuusio closed 8 years ago

illuusio commented 8 years ago

I'm facing problem that provides are not parsed in several Nodejs packages with new nodejs-packaging. For example:

https://build.opensuse.org/package/show/home:illuusio:nodejs-fedora/nodejs-invert-kv

It generates error

[   65s] /usr/lib64/ruby/2.0.0/json/common.rb:155:in `encode': "\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
[   65s]    from /usr/lib64/ruby/2.0.0/json/common.rb:155:in `initialize'
[   65s]    from /usr/lib64/ruby/2.0.0/json/common.rb:155:in `new'
[   65s]    from /usr/lib64/ruby/2.0.0/json/common.rb:155:in `parse'
[   65s]    from /usr/lib/rpm/nodejs.prov:26:in `block in <main>'
[   65s]    from /usr/lib/rpm/nodejs.prov:22:in `each'
[   65s]    from /usr/lib/rpm/nodejs.prov:22:in `<main>'
[   65s] /usr/lib64/ruby/2.0.0/json/common.rb:155:in `encode': "\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
[   65s]    from /usr/lib64/ruby/2.0.0/json/common.rb:155:in `initialize'
[   65s]    from /usr/lib64/ruby/2.0.0/json/common.rb:155:in `new'
[   65s]    from /usr/lib64/ruby/2.0.0/json/common.rb:155:in `parse'
[   65s]    from /usr/lib/rpm/nodejs.req:33:in `block in <main>'
[   65s]    from /usr/lib/rpm/nodejs.req:30:in `each'
[   65s]    from /usr/lib/rpm/nodejs.req:30:in `<main>'

Which I assume is caused by UTF-8 char or something JSON-stream. Ruby is not my best language but I try to dig this little more.

marguerite commented 8 years ago

US-ASCII was the default locale for OBS build worker.

I'll explicit convert the json to UTF-8

illuusio commented 8 years ago

How to overcome this then? Or have made some magic change in OBS?

marguerite commented 8 years ago

no you cant by yourself.

You can raise a bug in opensuse-buildservice@opensuse.org mailing list to ask them to set default locale of build worker to en_US.UTF-8. or everthing is opened in US-ASCII mode by default. which is your case.

or wait for my workaround in nodejs-packaging by open everything explicitly in UTF-8 mode. I can't do this now because it's midnight (GMT +0800), will do it tomorrow.

illuusio commented 8 years ago

Ok I'll wait because it also evening here and you will fix it before I'm up :dancer:

marguerite commented 8 years ago

commit 448f686 fixed this.

https://build.opensuse.org/package/binary/home:MargueriteSu:branches:devel:languages:nodejs/nodejs-invert-kv?arch=i586&filename=nodejs-invert-kv-1.0.0-9.1.noarch.rpm&repository=openSUSE_Tumbleweed

you can also use the nodejs-packaging there which is my devel test build

illuusio commented 8 years ago

Thank for the fast fix I'll try it and report another bug if needed