I think that’s because you’re trying to run the file directly, whereas the Rails app lives inside a Docker container. You need to run the file from the Docker container, otherwise the Rails application is not loaded and thus the Rake task will not work.
As you can see in Regis answer here https://meta.discourse.org/t/how-to-run-uploads-migrate-to-new-pattern-rake-task/29083/2, you enter the Docker container by doing the following:
- ssh into your server on DigitalOcean
cd /var/discourse
./launcher enter app
rake user_importer:check[tmp/users.csv]
Now it should work (haven’t tested it, and it’s a while that I’ve used Discourse, but I think it does).
The next issue will probably be getting your CSV file inside the Docker container. As far as I know and remember, you can used the shared folder for this, as this will be automatically mounted by the Docker container. To do so, do the following:
- On your server, save / move your CSV file in the
/var/discourse/shared/standalone
folder - Start the Docker container with
./launcher enter app
from the/var/discourse
folder, as in the previous steps above - Execute the command
cp /shared/users.csv tmp/users.csv
, this will copy the CSV file to the right directory for my script (changeusers.csv
to whatever the name of your file is)
You can read a little more on this here /shared folder not mounted in Docker container