# Fluentd gem test generates error "wrong number of arguments (1 for 0)"

**URL:** <https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371>\
**Category:** Development\
**Created:** [January 6, 2022, 6:49pm UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371 "2022-01-06T18:49:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 6, 2022, 6:49pm UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/1 "2022-01-06T18:49:43Z")

</div>

echo ‘{“message”:“hello”}’ | fluent-cat debug.log  
generates output:  
wrong number of arguments (1 for 0)

Please help to understand the issue. Many thanks.

---

<div class="post-metadata">

**Author:** ![jgomo3](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/jgomo3/32/950_2.png) [@jgomo3](https://www.ruby-forum.com/u/jgomo3)\
**Post date:** [January 14, 2022, 1:56am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/2 "2022-01-14T01:56:48Z")

</div>

I just tried the same example you are trying to do, as described in fluend’s [README](https://github.com/fluent/fluentd#readme) file:

```bash
gem install fluentd
fluentd -s conf
fluentd -c conf/fluent.conf &
echo '{"json":"message"}' | fluent-cat debug.test

```

And it just worked well.

What version of it have you installed?  
I have `1.14.4`:

```auto
fluentd --version
fluentd 1.14.4
ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

```

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 2:08am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/3 "2022-01-14T02:08:41Z")

</div>

Thank you.. This is what we have:

# fluentd --version

fluentd 0.12.43

# ruby -v

ruby 2.0.0p598 (2014-11-13 revision 48408) [i386-solaris2.10]

#

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 2:10am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/4 "2022-01-14T02:10:50Z")

</div>

Perhaps it is yajl-ruby issue?

2022-01-13 11:01:20 -0500 [warn]: fluent/root\_agent.rb:187:emit\_error\_event: dump an error event: error\_class=ArgumentError error=“wrong number of arguments (1 for 0)” location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’" tag=“fluent.warn” time=1642088924 record={“error\_class”=\>“ArgumentError”, “error”=\>“wrong number of arguments (1 for 0)”,

---

<div class="post-metadata">

**Author:** ![jgomo3](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/jgomo3/32/950_2.png) [@jgomo3](https://www.ruby-forum.com/u/jgomo3)\
**Post date:** [January 14, 2022, 2:54am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/5 "2022-01-14T02:54:56Z")

</div>

I installed that version of `Ruby` and `fluentd`, and the example worked fine (I do receive another kind of error, but the message is received well).

The `yajl-ruby` version is the same (`1.4.1`).

The error you are showing me says the problem is in line 80. The line 80 of my `yajl.rb` file is:

```ruby
      new(options).encode(obj, io, &block)

```

Both `new` and `encode` receive more than `0` arguments.

What is the content of the line 80 of the `yajl` file you have installed in your system?:

```auto
sed -n '80p' /opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb

```

Another thing I noticed, was that the configuration files created by the new fluentd and the old one are technically identical (they differ in some comments).

Make sure you are using a clean config file. I’m using [this one](http://ix.io/3M7A).

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 3:08am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/6 "2022-01-14T03:08:15Z")

</div>

# sed -n ‘80p’ /opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb

```
  new(options).encode(obj, io, &block)

```

#

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 3:11am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/7 "2022-01-14T03:11:29Z")

</div>

Also, perhaps something wrong is here in “initialize”?

class Projector  
def initialize(stream, read\_bufsize=4096)  
@stream = stream  
@buffer\_size = read\_bufsize  
end  
end

(80:in ` **initialize** ’" tag=“fluent.warn” time=16420  
88924 record={“error\_class”=\>“ArgumentError”, “error”=\>“wrong number of arguments (1 for 0)”,)

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 3:16am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/8 "2022-01-14T03:16:25Z")

</div>

**I don’t understand Ruby at all… but from a common logic I have replaced:**  
**==========================**  
\*\* class Projector\*\*  
\*\* def initialize(stream, read\_bufsize=4096)\*\*  
\*\* @stream = stream\*\*  
\*\* @buffer\_size = read\_bufsize\*\*  
\*\* end\*\*  
\*\* end\*\*  
**====================**  
**by \*\*  
 ======================  
\*\* class Projector**  
\*\* def initialize(stream)\*\*  
\*\* @stream = stream\*\*  
\*\* @buffer\_size = 4096\*\*  
\*\* end\*\*  
\*\* end\*\*  
**=============**

**What do you think? Thank you.**

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 3:29am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/9 "2022-01-14T03:29:00Z")

</div>

Please find my replies below. Many thanks for your time!

---

<div class="post-metadata">

**Author:** ![jgomo3](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/jgomo3/32/950_2.png) [@jgomo3](https://www.ruby-forum.com/u/jgomo3)\
**Post date:** [January 14, 2022, 3:56am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/10 "2022-01-14T03:56:42Z")

</div>

I wouldn’t modify the installed gems, over all because obviously you are working with a really old system with unsupported components (i.e. Ruby 2.0). At least, try to make a backup of whatever you are changing before proceeding.

In particular, that change is not necessary because `read_bufsize` is an optional parameter, so calling `initialize` with 1 or 2 parameters is valid. Calling it with 1 parameter, will assign `4096` to `read_bufsize` by default.

I would double check the configuration file.

I wanted to encourage you to upgrade your system, but I know it will be tough (is it really a Solaris 2.10 running on a 32 bits architecture?).

Something you could do is to install `byebug` and prepend the word `byebug` in the file `/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb`, maybe in the line `80` which will effectively add a breackpoint there and then debug. Or you can do a discarding process placing the brackpoints in that file at different sensible places until you catch the execution control in the debugger. Ideally you could locate in the line just before the exception raises, and then you can see what is happening.

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 4:13am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/12 "2022-01-14T04:13:57Z")

</div>

# uname -a

SunOS IrisDCIPIQlab 5.10 Generic\_150401-05 i86pc i386 i86pc

# 

It is Solaris 10.

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 4:17am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/13 "2022-01-14T04:17:31Z")

</div>

I’m trying to use @type tail as a with the same multiple error(s):

2022-01-13 23:12:24 -0500 [warn]: fluent/root\_agent.rb:187:emit\_error\_event: dump an error event: error\_class=ArgumentError error=“wrong number of arguments (1 for 0)” location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize'" tag="fluent.warn" time=1642133477 record={"error_class"=>"ArgumentError", "error"=>"wrong number of arguments (1 for 0)", "location"=>"/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’", “tag”=\>“fluent.warn”, “time”=\>1642133476, “record”=\>{“timestamp”=\>"[2022-01-13", “@timestamp”=\>“2022-01-13T23:11:16-05:00”, “tag”=\>“collectd.messages”}, “message”=\>“dump an error event: error\_class=ArgumentError error=“wrong number of arguments (1 for 0)” location=”/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’" tag=“collectd.messages” time=1642133476 record={“timestamp”=\>"[2022-01-13", “@timestamp”=\>“2022-01-13T23:11:16-05:00”, “tag”=\>“collectd.messages”}", “@timestamp”=\>“2022-01-13T23:11:17-05:00”}

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 4:19am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/14 "2022-01-14T04:19:45Z")

</div>

> [@jgomo3](#):
>
> I wanted to encourage you to upgrade your system

We have tried to install newer versions of Ruby and Fluentd many times with no success. Currently this is the only configuration which is started and running on Solaris 10.

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 4:26am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/15 "2022-01-14T04:26:38Z")

</div>

Can we ask… do you see following string in yajl.rb

require ‘yajl/yajl’

?

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 14, 2022, 4:50am UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/16 "2022-01-14T04:50:28Z")

</div>

# ldd -d /opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl/yajl.so

```
    libruby2.0.so.2 => /opt/csw/lib/libruby2.0.so.2
    libpthread.so.1 => /lib/libpthread.so.1
    librt.so.1 => /lib/librt.so.1
    libsocket.so.1 => /lib/libsocket.so.1
    libdl.so.1 => /lib/libdl.so.1
    libcrypt_d.so.1 => /usr/lib/libcrypt_d.so.1
    libm.so.2 => /lib/libm.so.2
    libc.so.1 => /lib/libc.so.1
    libaio.so.1 => /lib/libaio.so.1
    libmd.so.1 => /lib/libmd.so.1
    libnsl.so.1 => /lib/libnsl.so.1
    libgen.so.1 => /lib/libgen.so.1
    libmp.so.2 => /lib/libmp.so.2
    libscf.so.1 => /lib/libscf.so.1
    libdoor.so.1 => /lib/libdoor.so.1
    libuutil.so.1 => /lib/libuutil.so.1
    symbol not found: main (/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl/yajl.so)
    symbol not found: isinf (/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl/yajl.so)

```

#

---

<div class="post-metadata">

**Author:** ![dklein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecb155/32.png) [@dklein](https://www.ruby-forum.com/u/dklein)\
**Post date:** [January 21, 2022, 9:56pm UTC](https://www.ruby-forum.com/t/fluentd-gem-test-generates-error-wrong-number-of-arguments-1-for-0/262371/17 "2022-01-21T21:56:16Z")

</div>

Please clarify - can we trust this code in yajl-ruby gem yajl.rb file? ( **# TODO: this code smells, any ideas?** )

class Encoder  
def self.encode(obj, \*args, &block)  
**# TODO: this code smells, any ideas?**  
args.flatten!  
options = {}  
io = nil  
args.each do |arg|  
if arg.is\_a?(Hash)  
options = arg  
elsif arg.respond\_to?(:write)  
io = arg  
end  
end if args.any?  
new(options).encode(obj, io, &block)  
end  
end  
end

========= it generates following error:

2022-01-21 12:26:09 -0500 [warn]: fluent/root\_agent.rb:187:emit\_error\_event: dump an error event: error\_class=ArgumentError error=“wrong number of arguments (1 for 0)” location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize'" tag="fluent.warn" time=1642785969 record={"error_class"=>"ArgumentError", "error"=>"wrong number of arguments (1 for 0)", "location"=>"/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’", “tag”=\>“fluent.debug”, “time”=\>1642785969, “record”=\>{“message”=\>“fluentd main process get SIGINT”, “@timestamp”=\>“2022-01-21T12:26:09-05:00”}, “message”=\>“dump an error event: error\_class=ArgumentError error=“wrong number of arguments (1 for 0)” location=”/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’" tag=“fluent.debug” time=1642785969 record={“message”=\>“fluentd main process get SIGINT”, “@timestamp”=\>“2022-01-21T12:26:09-05:00”}", “@timestamp”=\>“2022-01-21T12:26:09-05:00”}
