Metodo non definito `sub!' visitando `/admin/upgrade`

Ho capito bene che eseguire manualmente rebuild app esegue l’aggiornamento e quindi aggira la necessità di accedere a quella pagina di aggiornamento, ma l’errore deve ancora essere corretto? Va bene, allora per ora lo ignorerò…

Poiché ho eseguito una ricompilazione manuale, la pagina di aggiornamento mostra ancora quell’errore… ma /logs mi restituisce questo:

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 Mi Piace

Una ricostruzione manuale dovrebbe risolvere completamente i problemi e la pagina /upgrade dovrebbe tornare disponibile.

Stai eseguendo un’installazione standard? Puoi comunicarci quali plugin hai installato?

1 Mi Piace

Installazione standard, ma ammetto che il sito è in funzione dal 2018 se non erro, quindi… ma almeno è basato su docker e sembra una configurazione standard. Come ho detto, finora tutto ha funzionato come previsto.

Plugin:

Ho ricostruito di nuovo, corretto i permessi ed eseguito alcuni comandi git config --global --add safe.directory …, ma la pagina /upgrade mostra ancora un errore e il 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 Mi Piace

Per favore, potresti provare a eseguire questi comandi

./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 

Ogni plugin dovrebbe avere un URL remoto mostrato nell’elenco. Sospetto, in base all’errore, che uno di essi non ce l’abbia :thinking:

L’output previsto è qualcosa di simile a

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 Mi Piace

Hu, nessuno dei plugin ha un URL remoto:

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:

Interessante… in realtà, nessuna delle directory ha nemmeno una cartella .git.

Scavando più a fondo, il modo in cui abbiamo installato i plugin mancava della parte sudo -E -u discourse nelle chiamate git clone … in containers/app.yml. Di nuovo, la riga esistente docker_manager non l’ha mai avuta.

Non credo che questo sia il problema.

Penso di aver suggerito loro di cambiare gli esempi quando hanno iniziato a suggerirlo, ma non ha ricevuto alcuna attenzione.

Ancora non lo faccio, ma penso che potrei iniziare, poiché potrebbe impedire a git di lamentarsi.

Huh! Questo è molto strano e spiegherebbe sicuramente l’errore. Sembra che manchi anche il .git del core di Discourse (dato che chat/poll/ecc. non hanno un URL).

Puoi condividere lo snippet di app.yml dove sono installati i plugin?

Anche questo è un po’ strano:

Suggerisce che hai una directory plugins all’interno della tua directory plugins :thinking:

2 Mi Piace

A volte, quando le persone scoprono che non c’è una sottodirectory .git, è perché qualcuno ha semplicemente copiato da un posto all’altro e la copia ha omesso i file nascosti. Questo non accadrebbe mai con un’installazione standard, ma potrebbe accadere dove c’è un po’ di storia di persone che fanno cose che credono di capire. (Il che intendo in senso positivo, ma può causare errori.)

2 Mi Piace

Questo è il modo in cui i plugin vengono installati da 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

C’era un mkdir plugins extra come primo comando, motivo per cui esisteva la cartella plugins (vuota). Ho rimosso quel residuo degli anni passati…

La cartella per i pacchetti installati secondo l’app.yml sopra hanno tutti una cartella .git all’interno.

Tornando all’elenco degli URL remoti… come utente 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:

Come utente 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

La mia ipotesi: i permessi sono completamente sballati. Questo sembra corretto (all’interno del container)?

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:34 .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

Qual è la configurazione prevista di proprietà/permessi?