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