Font Issue

I'm encountering an issue while deploying my app on Railway. Whenever I attempt to import the captcha-canvas package it raises the following error Error: libfontconfig.so.1: cannot open shared object file: No such file or directory. I've only encountered this issue on Railway
36 Replies
Percy
Percy16mo ago
Project ID: 605ca1f7-cb82-4615-baa5-cd740534065f
Brody
Brody16mo ago
try adding a nixpacks.toml file to your project with this
[phases.setup]
aptPkgs = ["...", "libfontconfig1"]
[phases.setup]
aptPkgs = ["...", "libfontconfig1"]
532115149
532115149OP16mo ago
same issue happening
Brody
Brody16mo ago
try this instead
[phases.setup]
nixPkgs = ["...", "fontconfig"]
[phases.setup]
nixPkgs = ["...", "fontconfig"]
532115149
532115149OP16mo ago
yeah its still happening 😭
Brody
Brody16mo ago
how can i be sure you are putting that nixpacks.toml in the right place
532115149
532115149OP16mo ago
Brody
Brody16mo ago
okay looks good ill look into this more i have an example project that uses canvas, this worked for me
[phases.setup]
aptPkgs = ["...", "fontconfig"]
[phases.setup]
aptPkgs = ["...", "fontconfig"]
532115149
532115149OP16mo ago
(╯°□°)╯︵ ┻━┻
532115149
532115149OP16mo ago
Brody
Brody16mo ago
what package are you using
532115149
532115149OP16mo ago
captcha-canvas
532115149
532115149OP16mo ago
yep
Brody
Brody16mo ago
that uses skia-canvas, and skia-canvas says you need to apt install libfontconfig1 this is how youd do that, but didnt work i think its time for a dockerfile id write one for you, can you share your package.json
532115149
532115149OP16mo ago
sorry, i’ve already shutdown my computer and got in bed. i’ll send it tomorrow when i’m home
Brody
Brody16mo ago
no problem, ill prep the dockerfile in the mean time
532115149
532115149OP16mo ago
{
"name": "kayots",
"version": "1.0.0",
"description": "A discord.js bot.",
"main": "app/index.ts",
"repository": "https://github.com/rxnk/kayots",
"author": "damian",
"license": "MIT",
"private": true,
"dependencies": {
"captcha-canvas": "^3.2.1",
"chalk": "4.0.0",
"discord.js": "^14.11.0",
"dotenv": "^16.3.1",
"ms": "^2.1.3",
"parse-ms": "^2.1.0",
"pretty-bytes": "5.6.0",
"pretty-ms": "7.0.1",
"prisma": "^5.1.1",
"skia-canvas": "^1.0.1",
"winston": "^3.10.0"
},
"devDependencies": {
"@types/node": "^20.4.2",
"eslint": "^8.45.0",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.1.6"
},
"scripts": {
"start": "ts-node app/index.ts",
"build": "tsc"
}
}
{
"name": "kayots",
"version": "1.0.0",
"description": "A discord.js bot.",
"main": "app/index.ts",
"repository": "https://github.com/rxnk/kayots",
"author": "damian",
"license": "MIT",
"private": true,
"dependencies": {
"captcha-canvas": "^3.2.1",
"chalk": "4.0.0",
"discord.js": "^14.11.0",
"dotenv": "^16.3.1",
"ms": "^2.1.3",
"parse-ms": "^2.1.0",
"pretty-bytes": "5.6.0",
"pretty-ms": "7.0.1",
"prisma": "^5.1.1",
"skia-canvas": "^1.0.1",
"winston": "^3.10.0"
},
"devDependencies": {
"@types/node": "^20.4.2",
"eslint": "^8.45.0",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.1.6"
},
"scripts": {
"start": "ts-node app/index.ts",
"build": "tsc"
}
}
Brody
Brody16mo ago
question, what is the purpose of building your app with tsc then using ts-node to start from the ts file, the build step then seems pointless?
532115149
532115149OP16mo ago
ngl im not sure. i just started working with TS ~2 weeks ago
Brody
Brody16mo ago
please come to a proper solution before we proceed, are you gonna use ts-node, or are you gonna build and then run the resulting javascript, please pick one
532115149
532115149OP16mo ago
ts-node I suppose
Brody
Brody16mo ago
okay then please remove the build script
root
root16mo ago
you could also try, with nixpacks.toml:
[phases.setup]
nixPkgs = ["...", "fontconfig"]
nixLibs = ["...", "fontconfig"]
[phases.setup]
nixPkgs = ["...", "fontconfig"]
nixLibs = ["...", "fontconfig"]
Brody
Brody16mo ago
does nixLibs make a difference?
root
root16mo ago
yes It sets env vars so that stuff can find the libraries you've installed
Brody
Brody16mo ago
how does one know if you should install a package as a nixPkg or a nixLib, or both, or if you can even install a given package as a Lib?
532115149
532115149OP16mo ago
this worked, the module loads now but there's still some kind of issue happening with the font
532115149
532115149OP16mo ago
(second command is from my local pc running the same code)
Brody
Brody16mo ago
looks like its missing fonts what font does it use
532115149
532115149OP16mo ago
Looks like its using Sans
532115149
532115149OP16mo ago
root
root16mo ago
that looks like sans to me? unless I'm misunderstanding
Brody
Brody16mo ago
yeah but tiny font
532115149
532115149OP16mo ago
sooo wut should I do
Brody
Brody16mo ago
Google lol 🙂 we don't know, sorry but once you do find a solution, we can do our best to help you apply the solution to your railway deployment
Want results from more Discord servers?
Add your server