Método no definido `sub!' al visitar `/admin/upgrade`

¿Entiendo correctamente que al hacer un rebuild app manual se realiza la actualización y, por lo tanto, se evita la necesidad de acceder a esa página de actualización, pero el error aún necesita ser corregido? Bien, entonces lo ignoraré por ahora…

Porque hice una reconstrucción manual y la página de actualización todavía muestra ese error… pero /logs me da esto:

NoMethodError (undefined method `sub!' for nil:NilClass)
app/controllers/application_controller.rb:420:in `block in with_resolved_locale'
app/controllers/application_controller.rb:420:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:228:in `call'
plugins/docker_manager/lib/docker_manager/git_repo.rb:85:in `url'
plugins/docker_manager/app/controllers/docker_manager/admin_controller.rb:30:in `block in repos'
plugins/docker_manager/app/controllers/docker_manager/admin_controller.rb:16:in `map!'
plugins/docker_manager/app/controllers/docker_manager/admin_controller.rb:16:in `repos'
actionpack (7.0.5.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.5.1) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.0.5.1) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
app/controllers/application_controller.rb:420:in `block in with_resolved_locale'
i18n (1.14.1) lib/i18n.rb:322:in `with_locale'
app/controllers/application_controller.rb:420:in `with_resolved_locale'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.5.1) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.5.1) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.5.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.5.1) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.5.1) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.5.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.5.1) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.5.1) lib/action_view/rendering.rb:39:in `process'
rack-mini-profiler (3.1.0) lib/mini_profiler/profiling_methods.rb:85:in `block in profile_method'

actionpack (7.0.5.1) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.5.1) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
actionpack (7.0.5.1) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:852:in `call'
railties (7.0.5.1) lib/rails/engine.rb:530:in `call'
railties (7.0.5.1) lib/rails/railtie.rb:226:in `public_send'
railties (7.0.5.1) lib/rails/railtie.rb:226:in `method_missing'
actionpack (7.0.5.1) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (7.0.5.1) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:852:in `call'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
rack (2.2.8) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.8) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.8) lib/rack/head.rb:12:in `call'
actionpack (7.0.5.1) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
rack (2.2.8) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.8) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/cookies.rb:704:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.5.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
logster (2.12.2) lib/logster/middleware/reporter.rb:43:in `call'
railties (7.0.5.1) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.5.1) lib/rails/rack/logger.rb:27:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
rack (2.2.8) lib/rack/method_override.rb:24:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (2.2.8) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/host_authorization.rb:131:in `call'
rack-mini-profiler (3.1.0) lib/mini_profiler.rb:260:in `call'
message_bus (4.3.7) lib/message_bus/rack/middleware.rb:60:in `call'
lib/middleware/request_tracker.rb:228:in `call'
railties (7.0.5.1) lib/rails/engine.rb:530:in `call'
railties (7.0.5.1) lib/rails/railtie.rb:226:in `public_send'
railties (7.0.5.1) lib/rails/railtie.rb:226:in `method_missing'
rack (2.2.8) lib/rack/urlmap.rb:74:in `block in call'
rack (2.2.8) lib/rack/urlmap.rb:58:in `each'
rack (2.2.8) lib/rack/urlmap.rb:58:in `call'
unicorn (6.1.0) lib/unicorn/http_server.rb:634:in `process_client'
unicorn (6.1.0) lib/unicorn/http_server.rb:739:in `worker_loop'
unicorn (6.1.0) lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn (6.1.0) lib/unicorn/http_server.rb:143:in `start'
unicorn (6.1.0) bin/unicorn:128:in `<top (required)>'
vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'
1 me gusta

Una reconstrucción manual debería solucionar completamente los problemas, y la página /upgrade debería volver a estar disponible.

¿Estás ejecutando una instalación estándar? ¿Puedes indicarnos qué plugins tienes instalados?

1 me gusta

Instalación estándar, pero admito que el sitio está funcionando desde 2018, si mal no recuerdo, así que… pero al menos está basado en docker y se siente como una configuración estándar. Como dije, hasta ahora todo funcionó como se esperaba.

Plugins:

Volví a compilar, arreglé los permisos y ejecuté algunos comandos git config --global --add safe.directory …, pero la página /upgrade todavía muestra un error y el log dice:

NoMethodError (undefined method `sub!' for nil:NilClass)
app/controllers/application_controller.rb:420:in `block in with_resolved_locale'
app/controllers/application_controller.rb:420:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/middleware/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:228:in `call'
1 me gusta

Por favor, ¿podrías intentar ejecutar estos comandos?

./launcher enter app
cd /var/www/discourse/plugins
su discourse
for d in *; do echo "$d: $(git -C $d config --get remote.origin.url)"; done 

Cada plugin debería tener una URL remota mostrada en la lista. Sospecho, basándome en el error, que uno de ellos no la tiene :thinking:

La salida esperada es algo como

chat: https://github.com/discourse/discourse.git
discourse-automation: https://github.com/discourse/discourse-automation
discourse-chat-integration: https://github.com/discourse/discourse-chat-integration.git
...
1 me gusta

Hu, ninguno de los plugins tiene una URL remota:

discourse@ocean-app:/var/www/discourse/plugins$ for d in *; do echo "$d: $(git -C $d config --get remote.origin.url)"; done
chat:
discourse-chat-integration:
discourse-details:
discourse-lazy-videos:
discourse-local-dates:
discourse-narrative-bot:
discourse-presence:
discourse-solved:
docker_manager:
plugins:
poll:
styleguide:

Interesante… en realidad, ninguno de los directorios tiene siquiera una carpeta .git.

Profundizando, la forma en que instalamos los plugins carecía de la parte sudo -E -u discourse en las llamadas git clone … en containers/app.yml. De nuevo, la línea existente docker_manager nunca tuvo esto.

No creo que ese sea el problema.

Creo que sugerí que cambiaran los ejemplos cuando empezaron a sugerirlo, pero no recibió atención.

Todavía no lo hago, pero creo que podría empezar, ya que podría evitar que git se queje.

¡Vaya! Eso es muy extraño y definitivamente explicaría el error. Parece que incluso falta el .git del núcleo de Discourse (ya que chat/poll/etc. no tienen URL).

¿Puedes compartir el fragmento de app.yml donde se instalan los plugins?

Esto también es un poco raro:

Sugiere que tienes un directorio de plugins dentro de tu directorio de plugins :thinking:

2 Me gusta

A veces, cuando la gente descubre que no hay un subdirectorio .git, es porque alguien hizo una simple copia de un lugar a otro, y la copia omitió los archivos ocultos. Esto nunca sucedería con una instalación estándar, pero podría ocurrir donde hay un historial de personas haciendo cosas que creen entender. (Lo cual digo de buena manera, pero puede causar errores).

2 Me gusta

Así es como se instalan los plugins desde app.yml

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-chat-integration.git

Había un mkdir plugins adicional como primer comando, por eso existía la carpeta plugins (vacía). Eliminé ese remanente de años anteriores…

La carpeta de los paquetes instalados según el app.yml anterior tiene una carpeta .git dentro.

Volviendo a listar las URLs remotas… como usuario discourse:

discourse@ocean-app:/var/www/discourse/plugins$ for d in *; do echo "$d: $(git -C $d config --get remote.origin.url)"; done
chat:
discourse-chat-integration: https://github.com/discourse/discourse-chat-integration.git
discourse-details:
discourse-lazy-videos:
discourse-local-dates:
discourse-narrative-bot:
discourse-presence:
discourse-solved: https://github.com/discourse/discourse-solved.git
docker_manager: https://github.com/discourse/docker_manager.git
poll:
styleguide:

Como usuario root:

root@ocean-app:/var/www/discourse/plugins# for d in *; do echo "$d: $(git -C $d config --get remote.origin.url)"; done
chat: https://github.com/discourse/discourse.git
discourse-chat-integration:
discourse-details: https://github.com/discourse/discourse.git
discourse-lazy-videos: https://github.com/discourse/discourse.git
discourse-local-dates: https://github.com/discourse/discourse.git
discourse-narrative-bot: https://github.com/discourse/discourse.git
discourse-presence: https://github.com/discourse/discourse.git
discourse-solved:
docker_manager: https://github.com/discourse/docker_manager.git
poll: https://github.com/discourse/discourse.git
styleguide: https://github.com/discourse/discourse.git

Mi suposición: los permisos están totalmente estropeados. ¿Esto parece correcto (dentro del contenedor)?

root@ocean-app:/var/www/discourse# ls -la
total 508
drwxr-xr-x 1 root      root        4096 Aug 10 15:38 .
drwxr-xr-x 1 root      root        4096 Jul 11 00:33 ..
drwxr-xr-x 1 root      root        4096 Jul 11 00:34 app
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 bin
-rw-r--r-- 1 root      root         316 Aug 10 14:36 Brewfile
drwxr-xr-x 1 root      root        4096 Jul 11 00:33 .bundle
drwxr-xr-x 1 root      root        4096 Aug 10 14:47 config
-rw-r--r-- 1 root      root         304 Aug 10 14:36 config.ru
-rw-r--r-- 1 root      root        1303 Aug 10 14:36 CONTRIBUTING.md
-rw-r--r-- 1 root      root        2347 Aug 10 14:36 COPYRIGHT.md
lrwxrwxrwx 1 root      root          10 Aug 10 14:36 d -> bin/docker
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 db
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 .devcontainer
-rw-r--r-- 1 root      root        1315 Aug 10 14:36 discourse.sublime-project
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 docs
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 documentation
-rw-r--r-- 1 root      root         305 Aug 10 14:36 .editorconfig
-rw-r--r-- 1 root      root         334 Aug 10 14:36 .eslintignore
-rw-r--r-- 1 root      root        1061 Aug 10 14:36 .eslintrc
-rw-r--r-- 1 root      root        7146 Aug 10 14:36 Gemfile
-rw-r--r-- 1 root      root       15678 Aug 10 14:36 Gemfile.lock
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 .git
-rw-r--r-- 1 root      root         852 Aug 10 14:36 .gitattributes
-rw-r--r-- 1 root      root        2205 Aug 10 14:36 .git-blame-ignore-revs
-rw-r--r-- 1 root      root         272 Aug 10 15:38 .gitconfig
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 .github
-rw-r--r-- 1 root      root        1282 Aug 10 14:36 .gitignore
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 images
-rw-r--r-- 1 root      root         279 Aug 10 14:36 jsconfig.base.json
-rw-r--r-- 1 root      root         432 Aug 10 14:36 .jsdoc
-rw-r--r-- 1 root      root        1937 Aug 10 14:36 lefthook.yml
drwxr-xr-x 1 root      root       12288 Aug 10 14:36 lib
-rw-r--r-- 1 root      root        1470 Aug 10 14:36 .licensed.yml
-rw-r--r-- 1 root      root         375 Aug 10 14:36 .licensee.json
-rw-r--r-- 1 root      root       18092 Aug 10 14:36 LICENSE.txt
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 log
drwxr-xr-x 1 root      root       20480 Aug 10 14:37 node_modules
-rw-r--r-- 1 root      root          21 Aug 10 14:36 .npmrc
-rw-r--r-- 1 root      root        3114 Aug 10 14:36 package.json
drwxr-xr-x 1 discourse discourse   4096 Aug 16 08:44 plugins
-rw-r--r-- 1 root      root         728 Aug 10 14:36 .prettierignore
-rw-r--r-- 1 root      root         283 Aug 10 14:36 .prettierrc
drwxr-xr-x 1 root      root        4096 Aug 14 00:42 public
-rwxr-xr-x 1 root      root         305 Aug 10 14:36 Rakefile
-rw-r--r-- 1 root      root        6753 Aug 10 14:36 README.md
-rw-r--r-- 1 root      root          25 Aug 10 14:36 .rspec
-rw-r--r-- 1 root      root         246 Aug 10 14:36 .rspec_parallel
-rw-r--r-- 1 root      root         290 Aug 10 14:36 .rubocop.yml
-rw-r--r-- 1 root      root          10 Aug 10 14:36 .ruby-gemset.sample
-rw-r--r-- 1 root      root           6 Aug 10 14:36 .ruby-version.sample
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 script
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 spec
-rw-r--r-- 1 root      root          66 Aug 10 14:36 .streerc
-rw-r--r-- 1 root      root        1054 Aug 10 14:36 .template-lintrc.js
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 test
drwxr-xrwx 1 discourse discourse   4096 Aug 10 15:16 tmp
-rw-r--r-- 1 root      root        2575 Aug 10 14:36 translator.yml
drwxr-xr-x 1 root      root        4096 Jul 11 00:34 vendor
drwxr-xr-x 1 root      root        4096 Aug 10 14:36 .vscode-sample
-rw-r--r-- 1 root      root      204458 Aug 10 14:36 yarn.lock

¿Cuál es la configuración esperada de propiedad/permisos?