coverband icon indicating copy to clipboard operation
coverband copied to clipboard

Issue on Coverband initializer on Ruby 3.1.2

Open dynelight opened this issue 2 years ago • 9 comments

I'm not sure if this is because I need to do any new or different write up for Ruby 3, but this fails:

# config/coverband.rb
Coverband.configure do |config|
  config.store = Coverband::Adapters::RedisStore.new(
    Redis.new(
      url: ENV['REDIS_URL'],
      ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
    )
  )
end
/Users/dynelight/Projects/v/config/initializers/coverband.rb:2:in `<main>': uninitialized constant Coverband (NameError)

dynelight avatar Jul 04 '22 05:07 dynelight

Are you sure you have it in your gemfile, if you have require: false you will need to require it manually in something like application.rb or remove the require: false from your gemfile. We have this running in several Ruby 3.1.2 apps without anything like this.

danmayer avatar Jul 07 '22 01:07 danmayer

sorry for the delay @dynelight I was on vacation so it took a bit to get back to you on the issue.

danmayer avatar Jul 07 '22 01:07 danmayer

No problem. I double checked and I don't have require: false:

gem 'coverband'

... on my gemfile.

Are you initializing in a similar way as me?

dynelight avatar Jul 07 '22 19:07 dynelight

Ah... sorry, the coverband configuration file should be config/coverband.rb not config/initializers/coverband.rb This came up in another recent github issue and I will be making some changes to help avoid this issue.... move the file and you should be good.

danmayer avatar Jul 07 '22 19:07 danmayer

Oh wow... is this a Ruby 3 issue? I'm having several initializers have this same problem

dynelight avatar Jul 07 '22 19:07 dynelight

No, this shouldn't be Ruby 3 and most things use initializers, I should perhaps allow that for Coverband, but it is a bit odd in that I need to bootstrap it BEFORE most of Rails is up and running, hence the unique configuration file location.

danmayer avatar Jul 07 '22 19:07 danmayer

=> Run `bin/rails server --help` for more startup options
Exiting
/Users/dynelight/Projects/v/config/routes.rb:27:in `block in <main>': uninitialized constant Coverband (NameError)

Routes file:

  mount Coverband::Reporters::Web.new, at: '/coverage', constraints: Routing::AdminConstraint.new

On the routes file, it doesn't find it..

% cat Gemfile.lock | grep coverband
    coverband (5.2.3)

dynelight avatar Jul 07 '22 19:07 dynelight

if you have bundler setup correctly it should definitely be there before routes... you can just require 'coverband' at the top of the routes file, but something seems odd about your setup.

danmayer avatar Jul 07 '22 23:07 danmayer

since some other folk shave also had some issues with configuration, I added an install task that makes it more clear where to add the config file.

https://github.com/danmayer/coverband/issues/450

danmayer avatar Jul 08 '22 23:07 danmayer