Cannot use most CLI commands in a Rails app with Hanami slices
- Dominant language
- Ruby
- Stars
- 33
- Forks
- 55
- Avg merge
- 8d 7h
- Merged PRs (30d)
- 2
Description
## Describe the bug
We are working to incrementally migrate a Rails application to Hanami, gradually replacing an area of the Rails code with its own dedicated slice as we go ([taking this post as inspiration and a template](https://discourse.hanakai.org/t/proof-of-concept-a-hanami-slice-in-a-rails-app/1168)). As such, we have Hanami stuff in `slices/**/*` and `config/initializers/load_hanami.rb`, but nothing in `config/app.rb`.
## To Reproduce
```
rails new ibis
cd ibis
bundle add hanami
cat << END_INITIALIZER > config/initializers/load_hanami.rb
require 'hanami'
module IbisHanami
class App < Hanami::App
prepare_container { |container| container.autoloader.ignore('app') }
end
end
Hanami.boot
END_INITIALIZER
mkdir -p slices/osprey
cat << END_SLICE > slices/osprey/my_class.rb
module Osprey
class MyClass
def call = 'Hello from slice!'
end
end
END_SLICE
hanami g slice pigeon # does not generate a new slice, instead gives the usage docs for creating a new Hanami app
```
## Expected behavior
It would be nice if there were a way to use the convenient CLI commands in applications that use hanami, but define their `Hanami::App` somewhere other than `config/app.rb`
## My environment
- Ruby version: 3.4
- OS: I have seen this on both Mac OS and Linux
Contributor guide
Research direction
Start by running the reproduction and tracing the CLI entry point for `hanami g slice`, especially how it discovers the Hanami app. Compare that behavior with the app defined in `config/initializers/load_hanami.rb` rather than `config/app.rb`; done means generating a slice works in this Rails setup without moving the app definition, with regression coverage for the scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100