実行環境
- Windows 10
- Rails 6.0.3.6
- Ruby 3.1.2
実践したこと
- gem 'kaminari'を追加し、ページネーションを実装しようとしていました。
- gem導入後、bootstrap用のビューテンプレートを作成しようとし、
rails g kaminari:views bootstrap4
のコマンドを実行したところ、
タイトルのようなエラーが発生したため、解決のプロセスをまとめます。
エラー内容
ターミナル
% rails g kaminari:views bootstrap4
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:117:in `initialize': Invalid argument @ rb_sysopen - https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master (Errno::EINVAL)
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:117:in `open'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:117:in `get_files_in_master'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:41:in `themes'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:30:in `copy_or_fetch'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `block in invoke_all'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `each'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `map'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `invoke_all'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/group.rb:232:in `dispatch'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/generators.rb:276:in `invoke'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/commands/generate/generate_command.rb:26:in `perform'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/command/base.rb:69:in `perform'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/command.rb:46:in `invoke'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/commands.rb:18:in `<main>'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.14.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.14.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from bin/rails:4:in `<main>'
解決方法
-
こちらの記事を参考にし、
$ bundle exec rails g kaminari:views bootstrap4
を実行しbundle経由で実行してあげると、導入することができました。
ターミナル
$ bundle exec rails g kaminari:views bootstrap4
downloading app/views/kaminari/_first_page.html.haml from kaminari_themes...
identical app/views/kaminari/_first_page.html.haml
downloading app/views/kaminari/_gap.html.haml from kaminari_themes...
identical app/views/kaminari/_gap.html.haml
downloading app/views/kaminari/_last_page.html.haml from kaminari_themes...
identical app/views/kaminari/_last_page.html.haml
downloading app/views/kaminari/_next_page.html.haml from kaminari_themes...
identical app/views/kaminari/_next_page.html.haml
downloading app/views/kaminari/_page.html.haml from kaminari_themes...
identical app/views/kaminari/_page.html.haml
downloading app/views/kaminari/_paginator.html.haml from kaminari_themes...
identical app/views/kaminari/_paginator.html.haml
downloading app/views/kaminari/_prev_page.html.haml from kaminari_themes...
identical app/views/kaminari/_prev_page.html.haml
同じエラーに遭遇している方の参考になれば幸いです。