質問編集履歴

2

追記

2022/08/25 00:24

投稿

senseIY
senseIY

score279

test CHANGED
File without changes
test CHANGED
@@ -30,6 +30,85 @@
30
30
  以下のエラーが発生してしまいました。assetsフォルダがないといけないようです。APIモードではassetsフォルダはいらないはずです
31
31
  ・[Railsガイド](https://railsguides.jp/asset_pipeline.html)を見ましたが、APIモードについての言及はありませんでした。また、[この記事](https://qiita.com/naoty_k/items/331b5fec0f02611f6134)からAPIモードではrails assets:precompileは不要なのではないかと推測しました。
32
32
 
33
+ ちなみにprecompile無しでそのまま[docker-compose -f docker-compose.production.yml up]すると、以下のエラーが発生してしまいます。このエラーがassets precompileしていないことが原因なのかどうか問題の切り分けをしています。
34
+ ```yml
35
+ api_1 | ! Unable to load application: I18n::InvalidLocaleData: can not load translations from /usr/local/bundle/bundler/gems/devise_token_auth-1a0483fbd125/config/locales/ja.yml: #<Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 20 column 7>
36
+ api_1 | bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
37
+ api_1 | /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:254:in `rescue in load_yml': can not load translations from /usr/local/bundle/bundler/gems/devise_token_auth-1a0483fbd125/config/locales/ja.yml: #<Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 20 column 7> (I18n::InvalidLocaleData)
38
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:246:in `load_yml'
39
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:228:in `load_file'
40
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:17:in `block in load_translations'
41
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:16:in `each'
42
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:16:in `load_translations'
43
+
44
+ ~省略
45
+ api_1 | from /usr/local/bin/bundle:25:in `load'
46
+ api_1 | from /usr/local/bin/bundle:25:in `<main>'
47
+ api_1 | /usr/local/lib/ruby/3.1.0/psych.rb:455:in `parse': (<unknown>): did not find expected key while parsing a block mapping at line 20 column 7 (Psych::SyntaxError)
48
+ api_1 | from /usr/local/lib/ruby/3.1.0/psych.rb:455:in `parse_stream'
49
+ api_1 | from /usr/local/lib/ruby/3.1.0/psych.rb:399:in `parse'
50
+ api_1 | from /usr/local/lib/ruby/3.1.0/psych.rb:272:in `unsafe_load'
51
+ api_1 | from /usr/local/bundle/gems/bootsnap-1.13.0/lib/bootsnap/compile_cache/yaml.rb:151:in `input_to_storage'
52
+ api_1 | from /usr/local/bundle/gems/bootsnap-1.13.0/lib/bootsnap/compile_cache/yaml.rb:254:in `fetch'
53
+ api_1 | from /usr/local/bundle/gems/bootsnap-1.13.0/lib/bootsnap/compile_cache/yaml.rb:254:in `unsafe_load_file'
54
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:249:in `load_yml'
55
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:228:in `load_file'
56
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:17:in `block in load_translations'
57
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:16:in `each'
58
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/base.rb:16:in `load_translations'
59
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/simple.rb:77:in `init_translations'
60
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/simple.rb:62:in `eager_load!'
61
+ api_1 | from /usr/local/bundle/gems/i18n-1.12.0/lib/i18n.rb:91:in `eager_load!'
62
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/application/finisher.rb:75:in `each'
63
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
64
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/initializable.rb:32:in `instance_exec'
65
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/initializable.rb:32:in `run'
66
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/initializable.rb:61:in `block in run_initializers'
67
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
68
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
69
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
70
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
71
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:347:in `each'
72
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:347:in `call'
73
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
74
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
75
+ api_1 | from /usr/local/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
76
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/initializable.rb:60:in `run_initializers'
77
+ api_1 | from /usr/local/bundle/gems/railties-7.0.3.1/lib/rails/application.rb:372:in `initialize!'
78
+ api_1 | from /myapp/config/environment.rb:5:in `<top (required)>'
79
+ api_1 | from config.ru:3:in `require_relative'
80
+ api_1 | from config.ru:3:in `block in <main>'
81
+ api_1 | from /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:116:in `eval'
82
+ api_1 | from /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:116:in `new_from_string'
83
+ api_1 | from /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:105:in `load_file'
84
+ api_1 | from /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:66:in `parse_file'
85
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/lib/puma/configuration.rb:348:in `load_rackup'
86
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/lib/puma/configuration.rb:270:in `app'
87
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/lib/puma/runner.rb:150:in `load_and_bind'
88
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/lib/puma/single.rb:44:in `run'
89
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/lib/puma/launcher.rb:182:in `run'
90
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/lib/puma/cli.rb:81:in `run'
91
+ api_1 | from /usr/local/bundle/gems/puma-5.6.4/bin/puma:10:in `<top (required)>'
92
+ api_1 | from /usr/local/bundle/bin/puma:25:in `load'
93
+ api_1 | from /usr/local/bundle/bin/puma:25:in `<top (required)>'
94
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
95
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
96
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
97
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
98
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
99
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
100
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
101
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
102
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
103
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
104
+ api_1 | from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
105
+ api_1 | from /usr/local/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
106
+ api_1 | from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
107
+ api_1 | from /usr/local/bin/bundle:25:in `load'
108
+ api_1 | from /usr/local/bin/bundle:25:in `<main>'
109
+ redictum_ver-20_api_1 exited with code 1
110
+ ```
111
+
33
112
  私の予想ですが、やはりrailsのAPIモードを使用する際には、本番環境であってもrails assets:precompile はいらないように思えます。とりあえず今発生しているエラーの原因を切り分けたいのでAPIモードにrails assets:precompileは必要なのか知りたいです。
34
113
  何かしらアドバイスがあればよろしくお願いいたします。
35
114
 

1

追記

2022/08/25 00:02

投稿

senseIY
senseIY

score279

test CHANGED
File without changes
test CHANGED
@@ -13,7 +13,7 @@
13
13
  require 'sprockets/railtie'
14
14
  ```
15
15
  これで再度buildしましたが、
16
- ```
16
+ ```yml
17
17
  api_1 | For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs
18
18
  api_1 | bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
19
19
  api_1 | /usr/local/bundle/gems/sprockets-rails-3.4.2/lib/sprockets/railtie.rb:110:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
@@ -27,7 +27,7 @@
27
27
  api_1 | and restart your server
28
28
  api_1 |
29
29
  ```
30
- 以下のエラーが発生してしまいました。
30
+ 以下のエラーが発生してしまいました。assetsフォルダがないといけないようです。APIモードではassetsフォルダはいらないはずです
31
31
  ・[Railsガイド](https://railsguides.jp/asset_pipeline.html)を見ましたが、APIモードについての言及はありませんでした。また、[この記事](https://qiita.com/naoty_k/items/331b5fec0f02611f6134)からAPIモードではrails assets:precompileは不要なのではないかと推測しました。
32
32
 
33
33
  私の予想ですが、やはりrailsのAPIモードを使用する際には、本番環境であってもrails assets:precompile はいらないように思えます。とりあえず今発生しているエラーの原因を切り分けたいのでAPIモードにrails assets:precompileは必要なのか知りたいです。