R
Railway15mo ago
lionel

Django app deployment crashes due to cffi and libffi

Trying to deploy a Django app to Railway. After it builds successfully the deployment crashes with this error: #10 378.9 Running setup.py install for cffi: started #10 378.9 Running setup.py install for cffi: finished with status 'error' #10 378.9 error: subprocess-exited-with-error #10 378.9 #10 378.9 × Running setup.py install for cffi did not run successfully. #10 378.9 │ exit code: 1 #10 378.9 ╰─> [60 lines of output] #10 378.9 Package libffi was not found in the pkg-config search path. #10 378.9 Perhaps you should add the directory containing libffi.pc' #10 378.9 to the PKG_CONFIG_PATH environment variable #10 378.9 No package 'libffi' found`
69 Replies
Percy
Percy15mo ago
Project ID: 4ad98339-d4b3-47d9-973d-7162b5b5fd9f
lionel
lionelOP15mo ago
4ad98339-d4b3-47d9-973d-7162b5b5fd9f
Brody
Brody15mo ago
ThallesComH
ThallesComH15mo ago
cool tool brody
Brody
Brody15mo ago
thamks
lionel
lionelOP15mo ago
there was attempt as well.
lionel
lionelOP15mo ago
mysqlclient is in the requirements.txt
Brody
Brody15mo ago
it wants MySQLdb though
lionel
lionelOP15mo ago
thanks that fixed that one what about the cffi error in this log?
Brody
Brody15mo ago
send your railway.json please
lionel
lionelOP15mo ago
Brody
Brody15mo ago
give this a try
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs", "libffi"]
},
"ci": {
"dependsOn": ["setup"],
"cmds": ["npm ci"]
}
}
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "python3 manage.py migrate && python3 manage.py collectstatic --no-input && gunicorn readinghood.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs", "libffi"]
},
"ci": {
"dependsOn": ["setup"],
"cmds": ["npm ci"]
}
}
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "python3 manage.py migrate && python3 manage.py collectstatic --no-input && gunicorn readinghood.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
lionel
lionelOP15mo ago
still not working
Brody
Brody15mo ago
send your requirements.txt please
Brody
Brody15mo ago
does your project use every one of those modules?
lionel
lionelOP15mo ago
probably not
Brody
Brody15mo ago
please remove everything you are not using, let me know when thats done
lionel
lionelOP15mo ago
kk one second sorry I have a question actually. Why is it still installing packages on an old version of requirements? I have changed the requirements.txt file so it shouldn't be doing that right?
Brody
Brody15mo ago
does the repo have the correct requirements.txt in it?
lionel
lionelOP15mo ago
yep anyway. it's somewhat working now. I think there's an issue with my database, as I can't run it locally after some changes will have to fix that first build logs are fine, but deploy logs get stuck on accessing database will get back to you thanks so far
Brody
Brody15mo ago
do you use a railway hosted database?
lionel
lionelOP15mo ago
yeah postgres
Brody
Brody15mo ago
can i see a screenshot of your service variables please
lionel
lionelOP15mo ago
what's that?
Brody
Brody15mo ago
the variables for the railway service
lionel
lionelOP15mo ago
No description
Brody
Brody15mo ago
sorry thats not what i asked for
lionel
lionelOP15mo ago
these ones?
No description
Brody
Brody15mo ago
that is a plugin i asked for the service variables
lionel
lionelOP15mo ago
No description
lionel
lionelOP15mo ago
this one?
Brody
Brody15mo ago
yes you should be using a reference variable, please delete that variable and replace it with a reference variable https://docs.railway.app/develop/variables#reference-variables
lionel
lionelOP15mo ago
No description
lionel
lionelOP15mo ago
which one should i use for postgresql?
Brody
Brody15mo ago
the same one you where already using, just this time its a reference
lionel
lionelOP15mo ago
like this?
lionel
lionelOP15mo ago
No description
lionel
lionelOP15mo ago
this way?
No description
Brody
Brody15mo ago
not at all can you please read the docs sections i linked
lionel
lionelOP15mo ago
No description
lionel
lionelOP15mo ago
?
Brody
Brody15mo ago
can you please read the docs sections i linked
lionel
lionelOP15mo ago
No description
Brody
Brody15mo ago
there we go now please show me your code that connects to the database
lionel
lionelOP15mo ago
Brody
Brody15mo ago
you are still using sqlite you will need to add the rest of the pstgres reference variables to your service and then configure your settings.py like this https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py#L81
lionel
lionelOP15mo ago
No description
No description
Brody
Brody15mo ago
looks fine at first glance
lionel
lionelOP15mo ago
so it works, but there's an issue with my code so its not working if that makes sense ahah
Brody
Brody15mo ago
whats your start command
lionel
lionelOP15mo ago
python3 manage.py migrate && python3 manage.py collectstatic --no-input && gunicorn readinghood.wsgi
Brody
Brody15mo ago
also looks good
lionel
lionelOP15mo ago
yeah its my code i was using a mysql database and it was working
Brody
Brody15mo ago
it was using sqlite not mysql
lionel
lionelOP15mo ago
yeah i changed to sqlite to use the mdn tutorial doesnt seem to work using sqlite nor postgres
Brody
Brody15mo ago
whats not working
lionel
lionelOP15mo ago
will retry with mysql and get back to you "django.db.utils.ProgrammingError: relation "book" does not exist LINE 1: SELECT DISTINCT "book"."Category" FROM "book""
Brody
Brody15mo ago
stay with postgres, mysql is costly
lionel
lionelOP15mo ago
kk
Brody
Brody15mo ago
just looks like a code issue to me tbh
lionel
lionelOP15mo ago
it does too. but why was it working with mysql? anyway i'll have a look at the code after lunch thanks man!
Brody
Brody15mo ago
no problem
Want results from more Discord servers?
Add your server