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
lionel15mo ago
4ad98339-d4b3-47d9-973d-7162b5b5fd9f
Brody
Brody15mo ago
ThallesComH
ThallesComH15mo ago
cool tool brody
Brody
Brody15mo ago
thamks
lionel
lionel14mo ago
there was attempt as well.
lionel
lionel14mo ago
mysqlclient is in the requirements.txt
Brody
Brody14mo ago
it wants MySQLdb though
lionel
lionel14mo ago
thanks that fixed that one what about the cffi error in this log?
Brody
Brody14mo ago
send your railway.json please
Brody
Brody14mo 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
lionel14mo ago
still not working
Brody
Brody14mo ago
send your requirements.txt please
Brody
Brody14mo ago
does your project use every one of those modules?
lionel
lionel14mo ago
probably not
Brody
Brody14mo ago
please remove everything you are not using, let me know when thats done
lionel
lionel14mo 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
Brody14mo ago
does the repo have the correct requirements.txt in it?
lionel
lionel14mo 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
Brody14mo ago
do you use a railway hosted database?
lionel
lionel14mo ago
yeah postgres
Brody
Brody14mo ago
can i see a screenshot of your service variables please
lionel
lionel14mo ago
what's that?
Brody
Brody14mo ago
the variables for the railway service
lionel
lionel14mo ago
No description
Brody
Brody14mo ago
sorry thats not what i asked for
lionel
lionel14mo ago
these ones?
No description
Brody
Brody14mo ago
that is a plugin i asked for the service variables
lionel
lionel14mo ago
No description
lionel
lionel14mo ago
this one?
Brody
Brody14mo 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
lionel14mo ago
No description
lionel
lionel14mo ago
which one should i use for postgresql?
Brody
Brody14mo ago
the same one you where already using, just this time its a reference
lionel
lionel14mo ago
like this?
lionel
lionel14mo ago
No description
lionel
lionel14mo ago
this way?
No description
Brody
Brody14mo ago
not at all can you please read the docs sections i linked
lionel
lionel14mo ago
No description
lionel
lionel14mo ago
?
Brody
Brody14mo ago
can you please read the docs sections i linked
lionel
lionel14mo ago
No description
Brody
Brody14mo ago
there we go now please show me your code that connects to the database
Brody
Brody14mo 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
lionel14mo ago
No description
No description
Brody
Brody14mo ago
looks fine at first glance
lionel
lionel14mo ago
so it works, but there's an issue with my code so its not working if that makes sense ahah
Brody
Brody14mo ago
whats your start command
lionel
lionel14mo ago
python3 manage.py migrate && python3 manage.py collectstatic --no-input && gunicorn readinghood.wsgi
Brody
Brody14mo ago
also looks good
lionel
lionel14mo ago
yeah its my code i was using a mysql database and it was working
Brody
Brody14mo ago
it was using sqlite not mysql
lionel
lionel14mo ago
yeah i changed to sqlite to use the mdn tutorial doesnt seem to work using sqlite nor postgres
Brody
Brody14mo ago
whats not working
lionel
lionel14mo 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
Brody14mo ago
stay with postgres, mysql is costly
lionel
lionel14mo ago
kk
Brody
Brody14mo ago
just looks like a code issue to me tbh
lionel
lionel14mo 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
Brody14mo ago
no problem
Want results from more Discord servers?
Add your server