vite_ruby
vite_ruby copied to clipboard
Dry::CLI::Command `delegate` method raises error when used in rails project
- [x] I have tried upgrading by running
bundle update vite_ruby
. - [x] I have read the troubleshooting section before opening an issue.
Description 📖
I am getting this error during deployment rake db:migrate
ArgumentError: unknown keyword: [:description, :examples, :arguments, :options, :params, :default_params, :required_arguments, :optional_arguments, :subcommands]
Reproduction 🐞
❯ rails c
Running Rails 7.0.6
Running Ruby 3.2.2
Running PostgreSQL 14.7 (Homebrew) on aarch64-apple-darwin22.1.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.202), 64-bit
Loading development environment (Rails 7.0.6)
irb(main):001:0> ViteRuby::CLI
/Users/horizon/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.0.6/lib/active_support/core_ext/module/delegation.rb:171:in `delegate': unknown keyword: [:description, :examples, :arguments, :options, :params, :default_params, :required_arguments, :optional_arguments, :subcommands] (ArgumentError)
irb(main):002:0>
Vite Ruby Info
Run bin/rake vite:info
and provide the output:
bin/vite present?: true
vite_ruby: 3.3.4
vite_rails: 3.0.15
rails: 7.0.6
node: v19.8.1
npm: 9.5.1
yarn: 1.22.19
pnpm:
ruby: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
installed packages:
[email protected] /Users/horizon/WebAdMIT
├─┬ @vitejs/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]
Logs 📜
14:57:43 rake aborted!
14:57:43 ArgumentError: unknown keyword: [:description, :examples, :arguments, :options, :params, :default_params, :required_arguments, :optional_arguments, :subcommands]
14:57:43 /home/app/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/core_ext/module/delegation.rb:171:in `delegate'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli/command.rb:375:in `<class:Command>'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli/command.rb:11:in `<class:CLI>'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli/command.rb:7:in `<module:Dry>'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli/command.rb:6:in `<top (required)>'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:13:in `<class:CLI>'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:10:in `<module:Dry>'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:6:in `<top (required)>'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/vite_ruby-3.3.4/lib/vite_ruby/cli.rb:3:in `<top (required)>'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:30:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:135:in `const_get'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:135:in `cget'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:176:in `block in actual_eager_load_dir'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:25:in `each'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:25:in `ls'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:164:in `actual_eager_load_dir'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:17:in `block (2 levels) in eager_load'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:16:in `each'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:16:in `block in eager_load'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader.rb:329:in `block in eager_load_all'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader.rb:327:in `each'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader.rb:327:in `eager_load_all'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application/finisher.rb:74:in `block in <module:Finisher>'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:32:in `instance_exec'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:32:in `run'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:61:in `block in run_initializers'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:60:in `run_initializers'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:372:in `initialize!'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/railtie.rb:226:in `public_send'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/railtie.rb:226:in `method_missing'
14:57:43 /opt/app/config/environment.rb:5:in `<top (required)>'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:348:in `require_environment!'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:506:in `block in run_tasks_blocks'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/airbrake-13.0.2/lib/airbrake/rake.rb:17:in `execute'
14:57:43 /home/app/bundle/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
14:57:43 /home/app/bundle/bin/bundle:113:in `load'
14:57:43 /home/app/bundle/bin/bundle:113:in `<main>'
14:57:43 Tasks: TOP => db:migrate => db:load_config => environment
14:57:43 (See full trace by running task with --trace)
14:57:43 command terminated with exit code 1
Output
Run DEBUG=vite-plugin-ruby:* bin/vite dev
or DEBUG=vite-plugin-ruby:* bin/vite build
and provide the output:
vite-plugin-ruby:config {
vite-plugin-ruby:config base: '/assets/',
vite-plugin-ruby:config build: {
vite-plugin-ruby:config emptyOutDir: true,
vite-plugin-ruby:config sourcemap: true,
vite-plugin-ruby:config commonjsOptions: { transformMixedEsModules: true },
vite-plugin-ruby:config assetsDir: 'assets',
vite-plugin-ruby:config manifest: true,
vite-plugin-ruby:config outDir: '../../public/assets',
vite-plugin-ruby:config rollupOptions: { input: [Object], output: [Object] }
vite-plugin-ruby:config },
vite-plugin-ruby:config envDir: '/Users/horizon/WebAdMIT',
vite-plugin-ruby:config root: '/Users/horizon/WebAdMIT/app/frontend',
vite-plugin-ruby:config server: {
vite-plugin-ruby:config fs: { allow: [Array], strict: true },
vite-plugin-ruby:config host: 'localhost',
vite-plugin-ruby:config https: false,
vite-plugin-ruby:config port: 3036,
vite-plugin-ruby:config strictPort: true,
vite-plugin-ruby:config hmr: { clientPort: 3036 }
vite-plugin-ruby:config },
vite-plugin-ruby:config entrypoints: {
vite-plugin-ruby:config 'entrypoints/application.js': '/Users/horizon/WebAdMIT/app/frontend/entrypoints/application.js',
vite-plugin-ruby:config 'entrypoints/application.scss': '/Users/horizon/WebAdMIT/app/frontend/entrypoints/application.scss',
vite-plugin-ruby:config 'entrypoints/components.js': '/Users/horizon/WebAdMIT/app/frontend/entrypoints/components.js',
vite-plugin-ruby:config 'entrypoints/dropdown.js': '/Users/horizon/WebAdMIT/app/frontend/entrypoints/dropdown.js',
vite-plugin-ruby:config 'entrypoints/trix.js': '/Users/horizon/WebAdMIT/app/frontend/entrypoints/trix.js'
vite-plugin-ruby:config }
vite-plugin-ruby:config } +0ms
Workaround
# config/application.rb
require 'dry/cli' # <-- top of file
Hi Andrii!
Seems unusual, ViteRuby::CLI
already requires dry/cli
. Could you provide a minimal reproduction?
Out of chance, are you using the classic autoloader instead of zeitwerk?
Hi @ElMassimo
The issue is in conflict between Forwardable#delegate
and activesupport's delegate
methods. If load dry/cli
before rails will load activesupport
everything works as expected.
https://github.com/dry-rb/dry-cli/blob/7978a525fb441fd7e542a41d4383eb0058df73b2/lib/dry/cli/command.rb#L373-L385
You can run ViteRuby::CLI
from rails console to reproduce the issue
You can run ViteRuby::CLI from rails console to reproduce the issue
That doesn't cause an error in all Rails applications, please provide a minimal reproduction.