A user encounters an error when running bundle exec rake s3:upload_assets on a non-Docker Discourse installation, initially due to not running the command inside the app container. After entering the container, they face a Could not locate Gemfile error, resolved by using sudo -E -u discourse. The next issue is a Seahorse::Client::NetworkingError related to S3 configuration. pfaffman clarifies that S3 environment variables are required, even without Docker, and should be set in the environment. The user resolves the issue by fixing a corrupted upload entry via rails c, ensuring uploads are directed to the correct domain (not a Cloudflare subdomain), and successfully migrating assets to S3 using rake uploads:migrate_to_s3. Finally, they clean up unused files with rake uploads:clean_upjoshhabka.
I am trying to do "bundle exec rake s3:upload_assets" as root and it yields the following erros: Could not locate Gemfile or .bundle/ directory.
I also tried doing it without root, using "sudo -E -u discourse bundle exec rake s3:upload_assets" and it yielded the following error: sudo: unknown user discourse sudo: error initializing audit plugin sudoers_audit
I did both commands in the following directory: /var/discourse
This is a normal installation, not using docker or anything.
Thank you! That got me further, I am now at this error:
root@redacted:/var/www/discourse# sudo -E -u discourse bundle exec rake s3:upload_assets
/root is not writable.
Bundler will use `/tmp/bundler20250409-510203-w6snye510203' as your home directory temporarily.
ERROR: Ensure S3 is configured in config/discourse.conf or environment vars```
I do have everything configured in the Discourse site settings. I am not using Docker so I would not need environment vars?
All of the S3 variables should be moved to hidden settings, as mostly no good can come from configuring them in the settings.
Sorry, and I forgot that you’re not using Docker. But yes, you still need to set them in the ENV variables. I do that in my development environment to restore databases from S3.
If you’re not doing this for a development environment, you’re very likely making a big mistakes.
Fixed it by doing the following - there were two errors.
First, I fixed the second error by doing the following:
rails c
Upload.find(386).destroy!
exit
This fixed the corrupt post(malformatted text or something)
Then the red errors on the screen were from using the random subdomain(provided by cloudflare) and uploading to that. I had to upload the files to the new domain(which includes my connected domain)