Doesn't work in Ruby 2.2
mariotux opened this issue · 5 comments
I tried to use the yabeda gems and after bundle install when I am going to run the rails s, I have this error.
option_names': undefined method
dry_initializer' for Yabeda::Counter:Class (NoMethodError)
I am trying to use them in a rails 4.2 project with ruby 2.2.1
Can you help me? thank you.
option_names: undefined method dry_initializer
That's weird and shouldn't be related to Rails version (and to rails at all). But it may be related to Ruby version (2.2 is very, very old).
Can you please execute following script and reproduce this?
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
ruby '2.2.1'
gem 'rails', '~> 4.2'
gem 'yabeda' # Insert your version constraints here
gem 'yabeda-rails'
gem 'yabeda-prometheus' # Insert your adapter here
end
Yabeda.configure do
group :your_app do
counter :bells_rang_count, comment: "Total number of bells being rang", tags: %i[bell_size]
end
end
Yabeda.configure!
Yabeda.your_app.bells_rang_count.increment({bell_size: 42}, by: 1)
puts Yabeda.your_app.bells_rang_count.values
Also please give me yabeda, yabeda-rails, and dry-initializer version you're using (you can find them all inside Gemfile.lock
) and full backtrace of the error (you can hide it under details tag)
Hello,
Thank you to answer so fast. I know that my ruby version is too old... in fact, the version is 2.2.10 :-) but it is too old as well.
I executed the script and the result is:
$home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-prometheus-0.1.5/lib/yabeda/prometheus.rb:4:in `require': cannot load such file -- prometheus/client (LoadError)
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-prometheus-0.1.5/lib/yabeda/prometheus.rb:4:in `<top (required)>'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:95:in `require'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:95:in `rescue in block in require'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:72:in `block in require'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `each'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `require'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.3/lib/bundler/inline.rb:70:in `gemfile'
from yabeda.rb:3:in `<main>'
After it, I added the prometheus-client gem and the result was:
$home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda/dsl/option_builder.rb:40:in `option_names': undefined method `dry_initializer' for Yabeda::Counter:Class (NoMethodError)
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda/dsl/option_builder.rb:45:in `unknown_options'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda/dsl/option_builder.rb:15:in `options_from'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda/dsl/metric_builder.rb:14:in `build'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda/dsl/class_methods.rb:41:in `counter'
from yabeda.rb:17:in `block (2 levels) in <main>'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda/dsl/class_methods.rb:35:in `group'
from yabeda.rb:16:in `block in <main>'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda.rb:70:in `class_eval'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda.rb:70:in `block in configure!'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda.rb:68:in `each'
from $home/.asdf/installs/ruby/2.2.10/lib/ruby/gems/2.2.0/gems/yabeda-0.8.0/lib/yabeda.rb:68:in `configure!'
from yabeda.rb:21:in `<main>'
Yeah, looks like issue with the ruby version. I didn't test Yabeda on versions below 2.3 I think.
Try to downgrade dry-initializer gem to 1.4.x maybe. Looks like it supported Ruby 2.2 in 1.4.1.
@Envek I tested the script with ruby 2.3.8 and it seems works as you expect, this was the result:
{{:bell_size=>42}=>1}
I started to work in the project upgrade to ruby 2.3.8, I will wait until have the upgrade finished to use the gems. Thank you for your support.
Thanks for confirming that it doesn't work in Ruby 2.2!