daff
daff copied to clipboard
[Ruby] Crash when generating diff with JSON output
I'm using daff Ruby gem version 1.3.27.
Given the sample CSV files:
id,name
1,Tom
2,Jerry
id,name
1,Tom A
When trying to generate diff in JSON output with this command:
daff.rb diff \
./t1.csv \
./t2.csv \
--context 0 \
--id "id" \
--output-format json \
--index \
--unordered \
--output ./diff.json
Then I got this error:
~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:892:in 'Coopy::Coopy#run': NameErrorHaxeException (NameErrorHaxeException)
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:907:in 'Coopy::Coopy#coopyhx'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:1024:in 'Coopy::Coopy.main'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/bin/daff.rb:3:in '<top (required)>'
from ~/.asdf/installs/ruby/3.4.4/bin/daff.rb:25:in 'Kernel#load'
from ~/.asdf/installs/ruby/3.4.4/bin/daff.rb:25:in '<main>'
~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/haxe/format/json_printer.rb:164:in 'Haxe::Format::JsonPrinter#fields_string': undefined local variable or method '__php__' for an instance of Haxe::Format::JsonPrinter (NameError)
v1 = str_pad("",((l - "".length) / c.length).ceil * c.length + "".length,c,__php__.call("STR_PAD_LEFT"))
^^^^^^^
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/haxe/format/json_printer.rb:32:in 'Haxe::Format::JsonPrinter#write'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/haxe/format/json_printer.rb:232:in 'Haxe::Format::JsonPrinter._print'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:158:in 'Coopy::Coopy#encode_table'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:134:in 'Coopy::Coopy#save_table'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:173:in 'Coopy::Coopy#save_tables'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:303:in 'Coopy::Coopy#run_diff'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:869:in 'Coopy::Coopy#run'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:907:in 'Coopy::Coopy#coopyhx'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/lib/lib/coopy/coopy.rb:1024:in 'Coopy::Coopy.main'
from ~/.asdf/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/daff-1.3.27/bin/daff.rb:3:in '<top (required)>'
from ~/.asdf/installs/ruby/3.4.4/bin/daff.rb:25:in 'Kernel#load'
from ~/.asdf/installs/ruby/3.4.4/bin/daff.rb:25:in '<main>