Thank you both for all the pointers and of course for the branch! I can confirm that the minimal sample works with that and that I get my larger sample to work also.
I had not yet subclassed action and view because I was leery of adding more dependencies and thus more things to work through and I am not using either in my example.
Here is the next version I have come up with:
rm -rf hanami_sample
rails new hanami_sample
cd hanami_sample
echo '
gem "hanami", github: "hanami/hanami", branch: "fix-error-in-operation-extension-for-no-db-apps"
gem "hanami-controller", "~> 2.2"
gem "hanami-view", "~> 2.2"
gem "dry-operation"
' >> Gemfile
bundle
cd tmp
bundle exec hanami new SportsballHanami
cd sportsball_hanami
bundle exec hanami generate slice HanamiPredictor
mv slices ../..
cd ../..
echo '# typed: ignore
require "dry/monads"
require "dry/operation"
require "hanami/action"
require "hanami/view"
module SportsballHanami
class App < Hanami::App
prepare_container do |container|
container.autoloader.ignore("app")
end
end
class Action < Hanami::Action
include Dry::Monads[:result]
end
class Operation < Dry::Operation
end
class View < Hanami::View
end
end
Hanami.boot
HanamiPredictor::Slice.boot
p Hanami.app.slices[:hanami_predictor].keys
' > config/initializers/load_hanami.rb
bin/rails runner 'puts "Hello, world!"'
This fails with
/Users/stephan/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/bundler/gems/hanami-27a002cd91c2/lib/hanami/provider/source.rb:8:in `initialize': missing keyword: :slice (ArgumentError)
from /Users/stephan/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/dry-configurable-1.3.0/lib/dry/configurable/instance_methods.rb:17:in `initialize'
from /Users/stephan/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/dry-system-1.2.2/lib/dry/system/provider.rb:140:in `new'
...
The loading problems go away if I remove the inheritance from < Hanami::View. Once removed, the script passes.