Okay, so I’ve tried using a volume, but I don’t understand how to access it. The script uses users.txt, which is a file containing a list of names. Locally, I’ve been using
The script adds new names to the file, and I need it to use persistent memory so that the names are always saved. I’ve created a 1 GB module and put this in my fly.toml:
And here’s my code for writing to the file:
# Read users.txt
with open(r'/bot/data/users.txt', 'r') as file:
users = [line.rstrip('\n') for line in file]
# Function for writing to users.txt
with open(r'/bot/data/users.txt', 'w') \
for item in users:
print('Current path:', os.getcwd())
print('Isdir reports:', os.path.isdir(os.getcwd()))
print('Isfile reports:', os.path.isfile(
My problem is that I don’t know what path to use to access users.txt. I don’t really understand how volumes work.
What I want: Store a text file called users.txt in
root\data to access in my script. It needs to be persistent, keeping the file’s contents when I re-deploy the application to update my code.
/bot/data/users.txt doesn’t seem to work for the path in my script. I’ve also tried
I’m getting the error
FileNotFoundError: [Errno 2] No such file or directory: '/data/users.txt'.
Umounting /dev/vdc from /data also shows up in the console, if that means anything.
If anyone can help me out with this, that would be much, much appreciated!