masaya7 / museum_app

0 stars 0 forks source link

Permission denied @ rb_sysopen 権限に関するエラー #45

Closed masaya7 closed 1 year ago

masaya7 commented 1 year ago

環境

rails7 ruby 3.2.2

現状

fly.ioにデプロイを行い、ゲストログインまで行える状況です。 新規投稿を行うとエラーが発生します。

行ったこと

ログを確認するとErrno::EACCES (Permission denied @ rb_sysopen - /rails/public/uploads/post/image/6/sample.png): ActionController::RoutingError (No route matches [GET] "/assets/controllers"): と2つのエラーが存在していました。

新しくfly deployしてから新規投稿するまでのログ

2023-08-15T14:30:07Z runner[32874541b33ed8] nrt [info]Configuring firecracker
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info]- Gracefully stopping, waiting for requests to finish
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info]=== puma shutdown: 2023-08-15 14:30:09 +0000 ===
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info]- Goodbye!
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info]Exiting
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info] INFO Sending signal SIGINT to main child process w/ PID 255
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info] INFO Main child exited normally with code: 0
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info] INFO Starting clean up.
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-08-15T14:30:09Z app[32874541b33ed8] nrt [info]2023/08/15 14:30:09 listening on [fdaa:2:93d2:a7b:fc:942b:e185:2]:22 (DNS: [fdaa::3]:53)
2023-08-15T14:30:10Z app[32874541b33ed8] nrt [info][  131.440844] reboot: Restarting system
2023-08-15T14:30:11Z app[32874541b33ed8] nrt [info][    0.035797] PCI: Fatal: No config space access function found
2023-08-15T14:30:11Z app[32874541b33ed8] nrt [info] INFO Starting init (commit: b437b5b)...
2023-08-15T14:30:11Z app[32874541b33ed8] nrt [info] INFO starting statics vsock server
2023-08-15T14:30:11Z app[32874541b33ed8] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails
2023-08-15T14:30:11Z app[32874541b33ed8] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-08-15T14:30:11Z app[32874541b33ed8] nrt [info]2023/08/15 14:30:11 listening on [fdaa:2:93d2:a7b:fc:942b:e185:2]:22 (DNS: [fdaa::3]:53)
2023-08-15T14:30:13Z app[32874541b33ed8] nrt [info]=> Booting Puma
2023-08-15T14:30:13Z app[32874541b33ed8] nrt [info]=> Rails 7.0.6 application starting in production
2023-08-15T14:30:13Z app[32874541b33ed8] nrt [info]=> Run `bin/rails server --help` for more startup options
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]Puma starting in single mode...
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]* Puma version: 5.6.6 (ruby 3.2.2-p53) ("Birdie's Version")
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]*  Min threads: 5
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]*  Max threads: 5
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]*  Environment: production
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]*          PID: 255
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]* Listening on http://0.0.0.0:3000
2023-08-15T14:30:14Z app[32874541b33ed8] nrt [info]Use Ctrl-C to stop
2023-08-15T14:30:41Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:30:41.706076 #255]  INFO -- : [3afc90d3-847f-4919-9e23-811a33540e45] Started GET "/" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:30:41 +0000
2023-08-15T14:30:41Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:30:41.707989 #255]  INFO -- : [3afc90d3-847f-4919-9e23-811a33540e45] Processing by ToppageController#top as HTML
2023-08-15T14:30:41Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:30:41.717182 #255]  INFO -- : [3afc90d3-847f-4919-9e23-811a33540e45]   Rendered toppage/top.html.erb within layouts/application (Duration: 6.3ms | Allocations: 2797)
2023-08-15T14:30:41Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:30:41.721611 #255]  INFO -- : [3afc90d3-847f-4919-9e23-811a33540e45]   Rendered layout layouts/application.html.erb (Duration: 11.0ms | Allocations: 5410)
2023-08-15T14:30:41Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:30:41.722011 #255]  INFO -- : [3afc90d3-847f-4919-9e23-811a33540e45] Completed 200 OK in 14ms (Views: 12.5ms | Allocations: 6774)
2023-08-15T14:30:42Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:30:42.018029 #255]  INFO -- : [9ead9687-414b-4f1b-a8b0-613cf4d4aea6] Started GET "/assets/controllers" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:30:42 +0000
2023-08-15T14:30:42Z app[e2865113b71048] nrt [info]F, [2023-08-15T14:30:42.018631 #255] FATAL -- : [9ead9687-414b-4f1b-a8b0-613cf4d4aea6]
2023-08-15T14:30:42Z app[e2865113b71048] nrt [info][9ead9687-414b-4f1b-a8b0-613cf4d4aea6] ActionController::RoutingError (No route matches [GET] "/assets/controllers"):
2023-08-15T14:30:42Z app[e2865113b71048] nrt [info][9ead9687-414b-4f1b-a8b0-613cf4d4aea6]
2023-08-15T14:31:22Z app[32874541b33ed8] nrt [info]I, [2023-08-15T14:31:22.324676 #255]  INFO -- : [76874a49-07b3-45df-8eec-38dc4b912db6] Started POST "/guest_login" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:31:22 +0000
2023-08-15T14:31:22Z app[32874541b33ed8] nrt [info]I, [2023-08-15T14:31:22.326863 #255]  INFO -- : [76874a49-07b3-45df-8eec-38dc4b912db6] Processing by GuestSessionsController#create as HTML
2023-08-15T14:31:22Z app[32874541b33ed8] nrt [info]I, [2023-08-15T14:31:22.326956 #255]  INFO -- : [76874a49-07b3-45df-8eec-38dc4b912db6]   Parameters: {"authenticity_token"=>"[FILTERED]"}
2023-08-15T14:31:22Z app[32874541b33ed8] nrt [info]I, [2023-08-15T14:31:22.390679 #255]  INFO -- : [76874a49-07b3-45df-8eec-38dc4b912db6] Redirected to https://frist-app.fly.dev/index
2023-08-15T14:31:22Z app[32874541b33ed8] nrt [info]I, [2023-08-15T14:31:22.391018 #255]  INFO -- : [76874a49-07b3-45df-8eec-38dc4b912db6] Completed 302 Found in 64ms (ActiveRecord: 21.0ms | Allocations: 11284)
2023-08-15T14:31:22Z app[e2865113b71048] nrt [info]ERROR No such file or directory (os error 2)
2023-08-15T14:31:22Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:22.405953 #255]  INFO -- : [93e1523b-a2cc-45a0-ae76-8d473c1022b7] Started GET "/index" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:31:22 +0000
2023-08-15T14:31:22Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:22.406705 #255]  INFO -- : [93e1523b-a2cc-45a0-ae76-8d473c1022b7] Processing by PostsController#index as HTML
2023-08-15T14:31:22Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:22.449746 #255]  INFO -- : [93e1523b-a2cc-45a0-ae76-8d473c1022b7]   Rendered posts/index.html.erb within layouts/application (Duration: 3.5ms | Allocations: 893)
2023-08-15T14:31:22Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:22.466990 #255]  INFO -- : [93e1523b-a2cc-45a0-ae76-8d473c1022b7]   Rendered layout layouts/application.html.erb (Duration: 20.7ms | Allocations: 7158)
2023-08-15T14:31:22Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:22.467367 #255]  INFO -- : [93e1523b-a2cc-45a0-ae76-8d473c1022b7] Completed 200 OK in 61ms (Views: 13.7ms | ActiveRecord: 22.2ms | Allocations: 13950)
2023-08-15T14:31:24Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:24.010095 #255]  INFO -- : [a9d60c74-fc85-4039-a9ba-dae6524f04a8] Started GET "/assets/controllers" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:31:24 +0000
2023-08-15T14:31:24Z app[e2865113b71048] nrt [info]F, [2023-08-15T14:31:24.010631 #255] FATAL -- : [a9d60c74-fc85-4039-a9ba-dae6524f04a8]
2023-08-15T14:31:24Z app[e2865113b71048] nrt [info][a9d60c74-fc85-4039-a9ba-dae6524f04a8] ActionController::RoutingError (No route matches [GET] "/assets/controllers"):
2023-08-15T14:31:24Z app[e2865113b71048] nrt [info][a9d60c74-fc85-4039-a9ba-dae6524f04a8]
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]ERROR No such file or directory (os error 2)
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:26.630901 #255]  INFO -- : [e2b3b1e2-a0fb-4e17-8b56-c0d19faf1fd4] Started GET "/posts/new" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:31:26 +0000
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:26.631694 #255]  INFO -- : [e2b3b1e2-a0fb-4e17-8b56-c0d19faf1fd4] Processing by PostsController#new as HTML
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:26.642533 #255]  INFO -- : [e2b3b1e2-a0fb-4e17-8b56-c0d19faf1fd4]   Rendered posts/new.html.erb within layouts/application (Duration: 2.9ms | Allocations: 1786)
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:26.652757 #255]  INFO -- : [e2b3b1e2-a0fb-4e17-8b56-c0d19faf1fd4]   Rendered layout layouts/application.html.erb (Duration: 13.1ms | Allocations: 3139)
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:26.653188 #255]  INFO -- : [e2b3b1e2-a0fb-4e17-8b56-c0d19faf1fd4] Completed 200 OK in 21ms (Views: 5.9ms | ActiveRecord: 10.3ms | Allocations: 6605)
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:26.783512 #255]  INFO -- : [7d84cfcb-3fe1-4d7a-88eb-8677afc667d5] Started GET "/assets/controllers" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:31:26 +0000
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info]F, [2023-08-15T14:31:26.784129 #255] FATAL -- : [7d84cfcb-3fe1-4d7a-88eb-8677afc667d5]
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info][7d84cfcb-3fe1-4d7a-88eb-8677afc667d5] ActionController::RoutingError (No route matches [GET] "/assets/controllers"):
2023-08-15T14:31:26Z app[e2865113b71048] nrt [info][7d84cfcb-3fe1-4d7a-88eb-8677afc667d5]
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:38.848696 #255]  INFO -- : [c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a] Started POST "/posts" for 2a09:8280:1::4e:57d9 at 2023-08-15 14:31:38 +0000
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:38.849730 #255]  INFO -- : [c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a] Processing by PostsController#create as HTML
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:38.849874 #255]  INFO -- : [c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a]   Parameters: {"authenticity_token"=>"[FILTERED]", "post"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x00007f03e1408440 @tempfile=#<Tempfile:/tmp/RackMultipart20230815-255-emnl2.png>, @content_type="image/png", @original_filename="sample.png", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"sample.png\"\r\nContent-Type: image/png\r\n">, "title"=>"sample", "body"=>"sample", "status"=>"published"}, "commit"=>"OK"}
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info]I, [2023-08-15T14:31:38.956187 #255]  INFO -- : [c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a] Completed 500 Internal Server Error in 106ms (ActiveRecord: 6.7ms | Allocations: 5621)
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info]F, [2023-08-15T14:31:38.956990 #255] FATAL -- : [c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a]
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info][c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a] Errno::EACCES (Permission denied @ rb_sysopen - /rails/public/uploads/post/image/7/sample.png):
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info][c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a]
2023-08-15T14:31:38Z app[e2865113b71048] nrt [info][c95e496e-4f62-4cf7-b8e0-d5e2a8d3946a] app/controllers/posts_controller.rb:17:in `create'
kerochelo commented 1 year ago

@masaya7

Errno::EACCES (Permission denied @ rb_sysopen - /rails/public/uploads/post/image/6/sample.png):

前者のこのエラー内容は投稿でアップデートされた画像に関して見れない系のエラーみたいですね。 本番環境時では、データベースや画像などユーザーによって作成される情報はアプリと同じサーバー内の場所に保存するよりも、S3などの外部のストレージサービスに保存するように設定する方が好ましいので、試してみてください!

参考:https://zenn.dev/kazuma_soon/articles/62f50c68eb011e

masaya7 commented 1 year ago

お疲れ様です。 いただいたリンクを実践するために、AWSを操作しております。 現在、AWSでアプリを動かしてみよう:gemのインストール まで行ったところで以下のようなエラーが発生しております。

Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to at least PostgreSQL-9.3.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
~~~(省略)~~~
An error occurred while installing pg (1.5.3), and Bundler cannot continue.

In Gemfile:
  pg

検索して見ると、PostgreSQLが古いためのエラーということがわかりました。そのため、入れ直し以下のようなバージョンにしました。

% psql --version                
psql (PostgreSQL) 15.4 (Homebrew)

しかし、同じエラーが引き続き発生してしまいます。どのようにすれば解消できるのかご教示願いたいです。 参考 参考2

エラー全文

[ec2-user@ip-172-31-39-174 museum_app]$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake 13.0.6
Using concurrent-ruby 1.2.2
Using i18n 1.14.1
Using minitest 5.18.1
Using tzinfo 2.0.6
Using activesupport 7.0.6
Using builder 3.2.4
Using erubi 1.12.0
Using racc 1.7.1
Using nokogiri 1.15.3 (x86_64-linux)
Using rails-dom-testing 2.1.1
Using crass 1.0.6
Using loofah 2.21.3
Using rails-html-sanitizer 1.6.0
Using actionview 7.0.6
Using rack 2.2.7
Using rack-test 2.1.0
Using actionpack 7.0.6
Using nio4r 2.5.9
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using actioncable 7.0.6
Using globalid 1.1.0
Using activejob 7.0.6
Using activemodel 7.0.6
Using activerecord 7.0.6
Using marcel 1.0.2
Using mini_mime 1.1.2
Using activestorage 7.0.6
Using date 3.3.3
Using timeout 0.4.0
Using net-protocol 0.2.1
Using net-imap 0.3.6
Using net-pop 0.1.2
Using net-smtp 0.3.3
Using mail 2.8.1
Using actionmailbox 7.0.6
Using actionmailer 7.0.6
Using actiontext 7.0.6
Using public_suffix 5.0.3
Using addressable 2.8.4
Using ast 2.4.2
Using execjs 2.8.1
Using autoprefixer-rails 10.4.13.0
Using bcrypt 3.1.19
Using bindex 0.8.1
Using popper_js 2.11.7
Using method_source 1.0.0
Using thor 1.2.2
Using zeitwerk 2.6.8
Using railties 7.0.6
Using ffi 1.15.5
Using sassc 2.4.0
Using sprockets 4.2.0
Using sprockets-rails 3.4.2
Using tilt 2.2.0
Using sassc-rails 2.1.2
Using bootstrap 5.2.3
Using bundler 2.4.10
Using matrix 0.4.2
Using regexp_parser 2.8.1
Using xpath 3.2.0
Using capybara 3.39.2
Using mini_magick 4.12.0
Using ruby-vips 2.1.4
Using image_processing 1.12.2
Using ssrf_filter 1.1.1
Using carrierwave 3.0.1
Using io-console 0.6.0
Using reline 0.3.6
Using irb 1.7.4
Using debug 1.8.0
Using diff-lcs 1.5.0
Using rails 7.0.6
Using dockerfile-rails 1.5.2
Using enum_help 0.0.19
Using factory_bot 6.2.1
Using factory_bot_rails 6.2.0
Using importmap-rails 1.2.1
Using jbuilder 2.11.5
Using jquery-rails 4.6.0
Using json 2.6.3
Using language_server-protocol 3.17.0.3
Using parallel 1.23.0
Using parser 3.2.2.3
Installing pg 1.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.5.3/ext
/home/ec2-user/.rbenv/versions/3.2.2/bin/ruby extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
Using libpq from /usr/lib64
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconninfo() in libpq-fe.h... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to at least PostgreSQL-9.3.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/ec2-user/.rbenv/versions/3.2.2/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-gvl-unlock
    --disable-gvl-unlock
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pq-dir
    --without-pq-dir
    --with-pq-include
    --without-pq-include=${pq-dir}/include
    --with-pq-lib
    --without-pq-lib=${pq-dir}/lib
    --with-pqlib
    --without-pqlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/pg-1.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.5.3 for inspection.
Results logged to /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/pg-1.5.3/gem_make.out

  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:119:in `run'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:27:in `build'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:187:in `build_extension'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:221:in `block in build_extensions'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:218:in `each'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:218:in `build_extensions'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/installer.rb:843:in `build_extensions'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/rubygems_gem_installer.rb:72:in `build_extensions'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/source/rubygems.rb:200:in `install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/gem_installer.rb:54:in `install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/parallel_installer.rb:156:in `do_install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/parallel_installer.rb:141:in `install_serially'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/parallel_installer.rb:91:in `call'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/parallel_installer.rb:67:in `call'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer.rb:244:in `install_in_parallel'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer.rb:201:in `install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer.rb:89:in `block in run'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/process_lock.rb:12:in `block in lock'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/process_lock.rb:9:in `open'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/process_lock.rb:9:in `lock'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer.rb:71:in `run'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/installer.rb:23:in `install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/cli/install.rb:62:in `run'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/cli.rb:261:in `block in install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/settings.rb:131:in `temporary'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/cli.rb:260:in `install'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in
`invoke_command'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/cli.rb:34:in `dispatch'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/cli.rb:28:in `start'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/exe/bundle:45:in `block in <top (required)>'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
  /home/ec2-user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/exe/bundle:33:in `<top (required)>'
  /home/ec2-user/.rbenv/versions/3.2.2/bin/bundle:25:in `load'
  /home/ec2-user/.rbenv/versions/3.2.2/bin/bundle:25:in `<main>'

An error occurred while installing pg (1.5.3), and Bundler cannot continue.

In Gemfile:
  pg
masaya7 commented 1 year ago

記述漏れがあったため、追記させていただきます。

RUNTEQカリキュラム内に

※ここでエラーとなりファイルの編集やgemの追加が必要になった場合は、EC2上で作業せずにローカルで作業してpushしたものをEC2上でpullしてください。
リポジトリのソースコードを更新しないと、別環境でデプロイした際に同じ内容のエラーが再発するため注意しましょう!

とあったため、ローカルにて作業行いました。

usuimasaya@usuishinyanoMacBook-Pro museum_app % git status
On branch correction
Your branch is ahead of 'origin/ fix' by 3 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   Gemfile
    modified:   Gemfile.lock

no changes added to commit (use "git add" and/or "git commit -a")
usuimasaya@usuishinyanoMacBook-Pro museum_app % git add .
usuimasaya@usuishinyanoMacBook-Pro museum_app % git commit -m '修正内容'
[correction ac98f48] 修正内容
 2 files changed, 5 insertions(+)
usuimasaya@usuishinyanoMacBook-Pro museum_app % git push origin correction
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 468 bytes | 468.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:masaya7/museum_app.git
   4d27c41..ac98f48  correction -> correction

その後ec2に行き、pullしました。

[ec2-user@ip-172-31-39-174 museum_app]$ git pull origin correction
remote: Enumerating objects: 89, done.
remote: Counting objects: 100% (89/89), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 54 (delta 43), reused 54 (delta 43), pack-reused 0
Unpacking objects: 100% (54/54), 17.22 KiB | 205.00 KiB/s, done.
From github.com:masaya7/museum_app
 * branch            correction -> FETCH_HEAD
   0e33e3d..ac98f48  correction -> origin/correction
Updating ac821c3..ac98f48
Fast-forward
 .yarnrc => .yarnrc.yml                                                   |   3 +-
 Gemfile                                                                  |  11 +++-
~~~

その後、再度bundle installを行いましたが、上記のエラーが残ってしまいます。

ロボらんてくんの回答

手順は次の通りダ:

ローカルPCでエディタを開き、エラーが発生したファイルを開くダ。
必要な修正やgemの追加を行って保存するダ。
ターミナルを開き、git add .と入力して全ての変更をステージングエリアに追加するダ。
次にgit commit -m "修正内容"と入力して、変更内容をコミットするダ。
最後にgit push origin ブランチ名と入力してGitHubにプッシュするダ。
それが終わったら、EC2のターミナルを開き、git pull origin ブランチ名と入力して最新のソースコードを取得するダ。
これでローカルでの修正内容がEC2に反映されるダゾ!ただし、再度デプロイを行う必要がある場合もあるから気をつけてダナ。
kerochelo commented 1 year ago

@masaya7 EC2で進めたんですね、勘違いさせてしまってすみません:bow: メインのRailsサーバーはFlyioでいいですが、画像などを保存する先をS3などの外部のストレージに修正するといった意味合いになります。

masaya7 commented 1 year ago

ありがとうございます。 早合点してしまい、申し訳ありません。 再度修正いたします。

kerochelo commented 1 year ago

@masaya7 上記の参考記事がわかりにくい場合は他のRailsとS3を利用している記事を参考にするといいかもしれないです!

masaya7 commented 1 year ago

CarrierwaveでS3にアップロードする方法 dotenv-railsを使って環境変数を管理しよう CarrierWaveを使って本番環境からS3に画像をアップロードする方法 上記サイトを参照しながら、行っております。 s3バケットや.envファイル、各gemのインストールまで実行しました。

多くの変更があったため、再度fly launchをしたのち、fly deployを実行したところ以下のようなエラーが発生してしまいました。

 => CACHED [build 7/8] COPY --link . .                                                                                                         0.0s
 => ERROR [build 8/8] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile                                                                  2.1s
------
 > [build 8/8] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile:
#0 2.047 Missing encryption key to decrypt file with. Ask your team for your master key and write it to /rails/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile]: exit code: 1

同じエラーで解消したものこちらを行いました。

より基本的な点が不足しているのかと思い、教本「実践ガイド」の/本番環境構築/環境変数/プリコンパイル/などを再読しております。特に今回のエラーにはdatabase.ymlの記述に問題があるのではと思っております。 また、関連あると思われるコード一覧を貼らせていただきます。申し訳ありませんがよろしくお願いいたいします。

/*エラー内容*/
% fly deploy                                                                              
 => CACHED [build 5/8] COPY --link package.json package-lock.json yarn.lock ./                                                                 0.0s
 => CACHED [build 6/8] RUN yarn install --frozen-lockfile                                                                                      0.0s
 => [build 7/8] COPY --link . .                                                                                                                1.8s
 => ERROR [build 8/8] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile                                                                  2.5s
------                                                                                                                                              
 > [build 8/8] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile:                                                                             
#0 2.508 rails aborted!                                                                                                                             
#0 2.508 LoadError: Could not load the 'postgres' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile.
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/abstract/connection_handler.rb:268:in `resolve_pool_config'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/abstract/connection_handler.rb:129:in `establish_connection'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_handling.rb:52:in `establish_connection'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/railtie.rb:268:in `block (2 levels) in <class:Railtie>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:95:in `class_eval'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:95:in `block in execute_hook'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:85:in `with_execution_control'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:90:in `execute_hook'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:76:in `block in run_load_hooks'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:75:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:75:in `run_load_hooks'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/base.rb:333:in `<module:ActiveRecord>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/base.rb:15:in `<top (required)>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/carrierwave-3.0.1/lib/carrierwave/orm/activerecord.rb:63:in `<top (required)>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/config/environment.rb:6:in `<top (required)>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:348:in `require_environment!'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:506:in `block in run_tasks_blocks'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/sentry-ruby-5.10.0/lib/sentry/rake.rb:24:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/sentry-ruby-5.10.0/lib/sentry/rake.rb:24:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands/rake/rake_command.rb:18:in `perform'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/command.rb:51:in `invoke'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands.rb:18:in `<top (required)>'
#0 2.508 
#0 2.508 Caused by:
#0 2.508 LoadError: cannot load such file -- active_record/connection_adapters/postgres_adapter
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/abstract/connection_handler.rb:268:in `resolve_pool_config'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/abstract/connection_handler.rb:129:in `establish_connection'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_handling.rb:52:in `establish_connection'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/railtie.rb:268:in `block (2 levels) in <class:Railtie>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:95:in `class_eval'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:95:in `block in execute_hook'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:85:in `with_execution_control'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:90:in `execute_hook'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:76:in `block in run_load_hooks'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:75:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/lazy_load_hooks.rb:75:in `run_load_hooks'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/base.rb:333:in `<module:ActiveRecord>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.6/lib/active_record/base.rb:15:in `<top (required)>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/carrierwave-3.0.1/lib/carrierwave/orm/activerecord.rb:63:in `<top (required)>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/config/environment.rb:6:in `<top (required)>'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:348:in `require_environment!'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/application.rb:506:in `block in run_tasks_blocks'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/sentry-ruby-5.10.0/lib/sentry/rake.rb:24:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/sentry-ruby-5.10.0/lib/sentry/rake.rb:24:in `execute'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands/rake/rake_command.rb:18:in `perform'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/command.rb:51:in `invoke'
#0 2.508 /rails/vendor/bundle/ruby/3.2.0/gems/railties-7.0.6/lib/rails/commands.rb:18:in `<top (required)>'
#0 2.508 Tasks: TOP => environment
#0 2.508 (See full trace by running task with --trace)
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile]: exit code: 1
masaya7 commented 1 year ago

お疲れ様です。

ただいま当初の目標であった"新規投稿"をすることができました。 以下のコードを追記・再インストールすることでエラー解消となりました。 長期に渡りご対応していただきありがとうございました。

# gemfile
group :production do
  gem 'fog-aws'
  gem 'pg'
  gem 'dotenv-rails'
  gem 'aws-sdk-s3'
end
# carrierwave.rb
require 'carrierwave/storage/abstract'
require 'carrierwave/storage/file'
require 'carrierwave/storage/fog'

CarrierWave.configure do |config|
  case Rails.env
  when 'development', 'test'
    config.storage = :file
    config.cache_storage = :file
  else
    config.fog_credentials = {
      provider: 'AWS',
      aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
      aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
      region: 'ap-northeast-1'
    }
    config.fog_provider = 'fog/aws'
    config.storage :fog
    config.cache_storage = :fog
    config.asset_host = "https://s3.ap-northeast-1.amazonaws.com/museum1-app"
    config.fog_directory = 'museum1-app'
    config.fog_public = false
  end
end
# database.yml
default: &default
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  adapter: sqlite3
  database: db/development.sqlite3

test:
  <<: *default
  adapter: sqlite3
  database: museum_msy_app_test

production:
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  database: museum_msy_app_production
  username: museunmsyapp
  password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>