Closed masaya7 closed 1 year ago
@masaya7
Errno::EACCES (Permission denied @ rb_sysopen - /rails/public/uploads/post/image/6/sample.png):
前者のこのエラー内容は投稿でアップデートされた画像に関して見れない系のエラーみたいですね。 本番環境時では、データベースや画像などユーザーによって作成される情報はアプリと同じサーバー内の場所に保存するよりも、S3などの外部のストレージサービスに保存するように設定する方が好ましいので、試してみてください!
お疲れ様です。 いただいたリンクを実践するために、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
記述漏れがあったため、追記させていただきます。
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に反映されるダゾ!ただし、再度デプロイを行う必要がある場合もあるから気をつけてダナ。
@masaya7 EC2で進めたんですね、勘違いさせてしまってすみません:bow: メインのRailsサーバーはFlyioでいいですが、画像などを保存する先をS3などの外部のストレージに修正するといった意味合いになります。
ありがとうございます。 早合点してしまい、申し訳ありません。 再度修正いたします。
@masaya7 上記の参考記事がわかりにくい場合は他のRailsとS3を利用している記事を参考にするといいかもしれないです!
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
お疲れ様です。
ただいま当初の目標であった"新規投稿"をすることができました。 以下のコードを追記・再インストールすることでエラー解消となりました。 長期に渡りご対応していただきありがとうございました。
# 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'] %>
環境
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つのエラーが存在していました。Errno::EACCES (Permission denied @ rb_sysopen - /rails/public/uploads/post/image/6/sample.png):
該当箇所に権限がないことがエラーの要因と考え、以下のように進めました。しかし、chmod -R 777 /rails/public/uploads/post/image
を実行しましたがエラーが解消できずにいるため、ご相談させていただきたいです。 imagesの後ろの数字(6)は新規投稿するたびに増えています。ActionController::RoutingError (No route matches [GET] "/assets/controllers"):
こちらに関してはもう少し検討したいと思っております。新しくfly deployしてから新規投稿するまでのログ