実装したいこと
-
ある記事を参考に
gem 'kaminari'
を導入してページネーション機能を作ろうとしておりました。 -
gemの導入後に、
% docker-compose run web rails g kaminari:views bootstrap4
コマンドを実行したところタイトルのようなエラーが発生したので解決に至るプロセスをまとめようと思います。
エラー内容
% docker-compose run web rails g kaminari:views bootstrap4
% docker-compose run web bundle exec rails g kaminari:views bootstrap4
Creating locat_web_run ... done
Running via Spring preloader in process 29
/usr/local/bundle/gems/kaminari-core-1.2.1/lib/generators/kaminari/views_generator.rb:117:in `initialize': No such file or directory @ rb_sysopen - https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master (Errno::ENOENT)
from /usr/local/bundle/gems/kaminari-core-1.2.1/lib/generators/kaminari/views_generator.rb:117:in `open'
from /usr/local/bundle/gems/kaminari-core-1.2.1/lib/generators/kaminari/views_generator.rb:117:in `get_files_in_master'
from /usr/local/bundle/gems/kaminari-core-1.2.1/lib/generators/kaminari/views_generator.rb:41:in `themes'
from /usr/local/bundle/gems/kaminari-core-1.2.1/lib/generators/kaminari/views_generator.rb:30:in `copy_or_fetch'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `block in invoke_all'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `each'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `map'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `invoke_all'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/group.rb:232:in `dispatch'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
from /usr/local/bundle/gems/railties-6.1.3.1/lib/rails/generators.rb:275:in `invoke'
from /usr/local/bundle/gems/railties-6.1.3.1/lib/rails/commands/generate/generate_command.rb:26:in `perform'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/bundle/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
from /usr/local/bundle/gems/railties-6.1.3.1/lib/rails/command/base.rb:69:in `perform'
from /usr/local/bundle/gems/railties-6.1.3.1/lib/rails/command.rb:50:in `invoke'
from /usr/local/bundle/gems/railties-6.1.3.1/lib/rails/commands.rb:18:in `<main>'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /usr/local/bundle/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
from /locat/bin/rails:5:in `<main>'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/commands/rails.rb:6:in `call'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/command_wrapper.rb:38:in `call'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:220:in `block in serve'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:10:in `block in fork'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:10:in `block in fork'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:8:in `fork'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:8:in `fork'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:26:in `fork'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:8:in `fork'
from /usr/local/bundle/gems/activesupport-6.1.3.1/lib/active_support/fork_tracker.rb:26:in `fork'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:180:in `serve'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
ERROR: 1
-
kaminari
導入後に、bootstrap4のページネーションのデザインに合わせたビューファイルを上記のコマンドで実行したところエラーが発生しデザインを適用できない状態になりました。 -
こちらの記事を参考にしたところ、既に
require 'open-uri'
は記述されていたためエラー解決できませんでした。
解決方法
-
こちらの記事を参考にしたところ、
-
gem 'kaminari'
を -
gem 'kaminari', git: 'https://github.com/kaminari/kaminari'
に修正した後にで解決できたと記載されていました。
-
- gemfileを修正後に
bundle install
を行い、再度コマンドを実行したところbootstrapが適用できました。
% docker-compose run web rails g kaminari:views bootstrap4
Creating locat_web_run ... done
Running via Spring preloader in process 29
downloading app/views/kaminari/_first_page.html.erb from kaminari_themes...
create app/views/kaminari/_first_page.html.erb
downloading app/views/kaminari/_gap.html.erb from kaminari_themes...
create app/views/kaminari/_gap.html.erb
downloading app/views/kaminari/_last_page.html.erb from kaminari_themes...
create app/views/kaminari/_last_page.html.erb
downloading app/views/kaminari/_next_page.html.erb from kaminari_themes...
create app/views/kaminari/_next_page.html.erb
downloading app/views/kaminari/_page.html.erb from kaminari_themes...
create app/views/kaminari/_page.html.erb
downloading app/views/kaminari/_paginator.html.erb from kaminari_themes...
create app/views/kaminari/_paginator.html.erb
downloading app/views/kaminari/_prev_page.html.erb from kaminari_themes...
create app/views/kaminari/_prev_page.html.erb
同じようなエラーに遭遇している方の参考になれば幸いです。
### 開発環境
- rubymine
- ruby(3.0.1)
- Ruby on rails (6.1.3.1)
- Docker (20.10.7)