Crash when consumer and app share the same name #235
-
I found a strange error when I was trying to create my first consumer with Racecar. I happened to use the same name for the Rails app and for the consumer. Somehow, the consumer wouldn't start, complaining about Here's how I created a plain consumer in a plain Rails app (Ruby 2.7.2, Rails 6.1.3, Racecar 2.2.0): $ rails new echo-consumer
$ cd echo-consumer
$ echo "gem 'racecar' >> Gemfile
$ bundle install
$ bundle exec rails generate racecar:install
$ bundle exec rails generate racecar:consumer Echo The app has no controllers and no models and does not use a database. The Here's what happens when I try to run the consumer: $ bundle exec racecar EchoConsumer
=> Starting Racecar consumer EchoConsumer...
=> Detected Rails, booting application...
=> Crashed: NoMethodError: undefined method `group_id' for EchoConsumer:Module
/Users/jean.tessier/.gem/ruby/2.7.2/gems/racecar-2.2.0/lib/racecar/config.rb:194:in `load_consumer_class'
/Users/jean.tessier/.gem/ruby/2.7.2/gems/racecar-2.2.0/lib/racecar/cli.rb:36:in `run'
/Users/jean.tessier/.gem/ruby/2.7.2/gems/racecar-2.2.0/lib/racecar/cli.rb:13:in `main'
/Users/jean.tessier/.gem/ruby/2.7.2/gems/racecar-2.2.0/exe/racecar:9:in `start'
/Users/jean.tessier/.gem/ruby/2.7.2/gems/racecar-2.2.0/exe/racecar:44:in `<top (required)>'
/Users/jean.tessier/.gem/ruby/2.7.2/bin/racecar:23:in `load'
/Users/jean.tessier/.gem/ruby/2.7.2/bin/racecar:23:in `<top (required)>'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/cli.rb:476:in `exec'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/cli.rb:24:in `start'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:46:in `block in <top (required)>'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/jean.tessier/.rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:34:in `<top (required)>'
/Users/jean.tessier/.rubies/ruby-2.7.2/bin/bundle:23:in `load'
/Users/jean.tessier/.rubies/ruby-2.7.2/bin/bundle:23:in `<main>' When It Works FineAs I was repeating my steps to document this issue, I created an app with a different name. Everything worked fine, in this case. I also tried moving the consumer to a module, like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Rails creates a module with the application name, so you cannot use the same name for a consumer class. |
Beta Was this translation helpful? Give feedback.
Rails creates a module with the application name, so you cannot use the same name for a consumer class.