[mutlisite installation] pnpm permission error during rebuild

AI-generated summary

Padoup-Padoup reported a failure when upgrading their web_only container in a multisite setup, specifically during the multisite:migrate task. The error logs indicated EACCES: permission denied when pnpm attempted to create directories in /root, despite the script attempting to use a temporary folder. supermathie identified the root cause as a missing -H flag in the command, explaining that sudo -E -u discourse should be replaced with sudo -H -E -u discourse to correctly set the home directory. Padoup-Padoup confirmed this solution resolved the issue, noting they had followed outdated tutorials that contained the incorrect command. While zogstrip and Jagster briefly discussed potential correlations with recent pnpm upgrades, the consensus was that the missing -H flag was the definitive fix for this specific permission error.

Hello,

I am unable to upgrade/rebuild my web_only container. The rebuild seems to fail when calling multisite migrate. A fresh install (no data, just my data.yml and web_only.yml files) yields the same error (the rebuild of the data container completes without error.

Am I doing anything wrong or could it be a bug introduced in a recent upgrade?

Alternatively, how could I circumvent this error? I don’t know the internals of the script but the scripts first says that /root/ is unwriteable, creates a tmp folder then seems to crash because mkdir fails in the /root/ directory.

Many thanks!

> Seeding theme and color schemes
I, [2026-01-16T17:32:37.738763 #1]  INFO -- : > cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate
`/root` is not writable.
Bundler will use `/tmp/bundler20260116-787-ovvxnu787' as your home directory temporarily.
rake aborted!
Discourse::Utils::CommandError: pnpm -C=frontend/asset-processor node build.js (Discourse::Utils::CommandError)
 WARN  Issue while reading "/root/.npmrc". EACCES: permission denied, open '/root/.npmrc'
 WARN  Issue while reading "/root/.config/pnpm/rc". EACCES: permission denied, open '/root/.config/pnpm/rc'
 ERROR  EACCES: permission denied, mkdir '/root/.local/share/pnpm/.tools/pnpm/10.28.0_tmp_901'
For help, run: pnpm help run
/var/www/discourse/lib/discourse.rb:171:in `execute_command'
/var/www/discourse/lib/discourse.rb:137:in `exec'
/var/www/discourse/lib/discourse.rb:32:in `execute_command'
/var/www/discourse/lib/asset_processor.rb:27:in `build_asset_processor'
/var/www/discourse/lib/asset_processor.rb:31:in `build_production_asset_processor'
/var/www/discourse/lib/tasks/assets.rake:155:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.3.1/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => multisite:migrate => assets:precompile:asset_processor
(See full trace by running task with --trace)


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate failed with return #<Process::Status: pid 785 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.4.0/lib/pups/exec_command.rb:138:in `spawn'
exec failed with the params "cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate"
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

@david / @cvx could this be related to pnpm upgrade we did recently? :thinking:

this should be sudo -H -E -u discourse…

(we should probably make set_home the default)

It is unbelievable to me that I received the exact answer after… 25min :tada:!

Many many thanks, the rebuild completed with success!

Indeed, my web_only.yml contained the incorrect command. I remember following one of these tutorials: (that still contain the now-incorrect command ; not sure how to edit those posts).

Yes it could, because I was in troubles when upgrade failed when wanting v10 and I had 9.something. So, I updated pnmp manually.

And yes, I’m off topic because mine isn’t multisite and OP had different issue