R
Railwayā€¢14mo ago
GetPsyched

sveltekit service crashing :(

I just deployed my brand new project on Railway and it tried running the bun run start command repeatedly which kept failing with the following error:
TERM environment variable not set.
error: script "start" exited with code 1 (SIGHUP)
TERM environment variable not set.
error: script "start" exited with code 1 (SIGHUP)
The service inevitably crashed.
121 Replies
Percy
Percyā€¢14mo ago
Project ID: 12b919b0-8ae8-4936-a695-591b96aa0d64
GetPsyched
GetPsychedOPā€¢14mo ago
Perhaps this is because I don't have any adapter setup?
Brody
Brodyā€¢14mo ago
definitely is, you would want to use the node adapter and hope it's compatible with bun, if it's not then you have to use nodejs
GetPsyched
GetPsychedOPā€¢14mo ago
Switching to nodejs shouldn't be a problem Will try adding the node adapter Tried adding the node adapter. The issue persists. I doubt this is because of bun since it works on my local machine cc @Brody
Brody
Brodyā€¢14mo ago
term environment variable not set issue still?
GetPsyched
GetPsychedOPā€¢14mo ago
yes the logs look identical to before adding the adapter
Brody
Brodyā€¢14mo ago
what is your start script
GetPsyched
GetPsychedOPā€¢14mo ago
the default? I didn't alter anything on Railway
Brody
Brodyā€¢14mo ago
what is it
GetPsyched
GetPsychedOPā€¢14mo ago
checking
GetPsyched
GetPsychedOPā€¢14mo ago
nothing?
No description
Brody
Brodyā€¢14mo ago
not quite what I asked the start script.. in the package.json
GetPsyched
GetPsychedOPā€¢14mo ago
Ah! bun run css && vite build && clear && vite preview css being: bunx tailwindcss -i ./src/app.css -o ./dist/tailwind.css
Brody
Brodyā€¢14mo ago
that's not a start script or at least it shouldn't be yours
GetPsyched
GetPsychedOPā€¢14mo ago
"scripts": {
"css": "bunx tailwindcss -i ./src/app.css -o ./dist/tailwind.css",
"dev": "bun run css && vite dev",
"build": "bun run css && vite build",
"preview": "bun run css && vite preview",
"start": "bun run css && vite build && clear && vite preview"
},
"scripts": {
"css": "bunx tailwindcss -i ./src/app.css -o ./dist/tailwind.css",
"dev": "bun run css && vite dev",
"build": "bun run css && vite build",
"preview": "bun run css && vite preview",
"start": "bun run css && vite build && clear && vite preview"
},
what should it be then
Brody
Brodyā€¢14mo ago
just start the node server
GetPsyched
GetPsychedOPā€¢14mo ago
so bun run css && vite build && node build? ref: https://kit.svelte.dev/docs/adapter-node
Brody
Brodyā€¢14mo ago
haha I've seen the node adapter docs, have you lol
GetPsyched
GetPsychedOPā€¢14mo ago
:(
Brody
Brodyā€¢14mo ago
you already run css and build in your build script, why are you running them again?
GetPsyched
GetPsychedOPā€¢14mo ago
right so bun run build && node build
Brody
Brodyā€¢14mo ago
you already run build in your build script, why are you running it again?
GetPsyched
GetPsychedOPā€¢14mo ago
OH oh yeah lol it's 2 am here sorry
Brody
Brodyā€¢14mo ago
and while node build might work, you should be more explicit and specify the full path to the JavaScript file that you want to run
GetPsyched
GetPsychedOPā€¢14mo ago
I don't have any specific JS file to run?
Brody
Brodyā€¢14mo ago
yes you do
GetPsyched
GetPsychedOPā€¢14mo ago
I simply have these
No description
Brody
Brodyā€¢14mo ago
vite build makes one with the node adapter
GetPsyched
GetPsychedOPā€¢14mo ago
ah, build/index.js
Brody
Brodyā€¢14mo ago
have a read šŸ˜‰ node build/index.js would use node to run the server, I thought you wanted to use bun?
GetPsyched
GetPsychedOPā€¢14mo ago
And you'd be right. I'm looking for a bun equivalent rn lol But yeah a more critical error would be: Error: Prince#execute: cannot resolve binary "prince" to a filesystem path šŸ˜” headed to prince docs or wait is there a way to install prince to the project env in Railway? like I did with SQLC back then some TOML file
Brody
Brodyā€¢14mo ago
well what is prince
GetPsyched
GetPsychedOPā€¢14mo ago
it is a tool that compiles HTML -> PDF among some other things I've defined it in my flake.nix, but Railway doesn't refer that šŸ˜” PrinceXML to be precise
Brody
Brodyā€¢14mo ago
is it available as a nix package or an apt package?
GetPsyched
GetPsychedOPā€¢14mo ago
nix package likely both oh wait it isn't available as a nix package I wrote my own package for it it's in the same project folder, is it possible for Railway to refer to that rather than nixpkgs?
Brody
Brodyā€¢14mo ago
is it an overlay?
GetPsyched
GetPsychedOPā€¢14mo ago
no, I just wrote my own package for it very tiny script:
{ autoPatchelfHook, fetchurl, fontconfig, glibc, stdenv }:

stdenv.mkDerivation rec {
pname = "princexml";
version = "15.1";
src = fetchurl {
url = "https://www.princexml.com/download/prince-${version}-linux-generic-x86_64.tar.gz";
hash = "sha256-rm0GeKPa8iDXBhW52GNcja09Qb+aYUtvFaxZUFHEOTw=";
};

nativeBuildInputs = [ autoPatchelfHook ];

buildInputs = [
fontconfig
glibc
];

installPhase = ''
./install.sh $out
ln -sf /var/lib/prince/license.dat $out/lib/prince/license/license.dat
'';
}
{ autoPatchelfHook, fetchurl, fontconfig, glibc, stdenv }:

stdenv.mkDerivation rec {
pname = "princexml";
version = "15.1";
src = fetchurl {
url = "https://www.princexml.com/download/prince-${version}-linux-generic-x86_64.tar.gz";
hash = "sha256-rm0GeKPa8iDXBhW52GNcja09Qb+aYUtvFaxZUFHEOTw=";
};

nativeBuildInputs = [ autoPatchelfHook ];

buildInputs = [
fontconfig
glibc
];

installPhase = ''
./install.sh $out
ln -sf /var/lib/prince/license.dat $out/lib/prince/license/license.dat
'';
}
GetPsyched
GetPsychedOPā€¢14mo ago
it is available on Ubuntu. I'm guessing that means it's on apt, by extension?
No description
Brody
Brodyā€¢14mo ago
what's it named
GetPsyched
GetPsychedOPā€¢14mo ago
checking should be princexml
GetPsyched
GetPsychedOPā€¢14mo ago
yeah I can't find it either
Brody
Brodyā€¢14mo ago
looks like you will have to install install prince the same sort of way i install caddy here https://github.com/brody192/vite-react-template/blob/main/nixpacks.toml
GetPsyched
GetPsychedOPā€¢14mo ago
On that note did the team say anything about flake support? would fix all my dependency issues
Brody
Brodyā€¢14mo ago
they want to support it natively, its just a low priority because few people use it
GetPsyched
GetPsychedOPā€¢14mo ago
:( I see Makes perfect sense from a business POV but still a bummer lol
Brody
Brodyā€¢14mo ago
but if you can write nix packages, writing a nixpacks.toml file would be no issue
GetPsyched
GetPsychedOPā€¢14mo ago
It's about understanding how the toml works either way, this script is extremely tiny, so you're right, it should be relatively simple
Brody
Brodyā€¢14mo ago
if you can understand how nix packages work, you can understand nixpacks.toml
GetPsyched
GetPsychedOPā€¢14mo ago
yes BTW, can I not use bun run preview as my start script? it expanding to bun run css && vite preview
Brody
Brodyā€¢14mo ago
that starts a dev server
GetPsyched
GetPsychedOPā€¢14mo ago
rip
Brody
Brodyā€¢14mo ago
use bun to run the index.js file
GetPsyched
GetPsychedOPā€¢14mo ago
because apparently there's a lot of pain happening
No description
GetPsyched
GetPsychedOPā€¢14mo ago
I will just switch to nodejs
Brody
Brodyā€¢14mo ago
its for the better
GetPsyched
GetPsychedOPā€¢14mo ago
indeed invalid use of variables? ERROR: failed to solve: process "/bin/bash -ol pipefail -c tar -zxvf ${pname}.tar.gz ${pname}" did not complete successfully: exit code: 2
Brody
Brodyā€¢14mo ago
lets see the nixpacks.toml file
GetPsyched
GetPsychedOPā€¢14mo ago
it likely won't work as it's the first draft just wanted to see what breaks huh I didn't delete it
Brody
Brodyā€¢14mo ago
you edited it
GetPsyched
GetPsychedOPā€¢14mo ago
# https://nixpacks.com/docs/configuration/file

[variables]
pname = 'princexml'
version = '15.1'

[phases.setup]
nixPkgs = ['...', 'corefonts', 'fontconfig', 'glibc']

[phases.princexml]
dependsOn = ['setup'] # make sure this phase runs after the default 'setup' phase
cmds = [
'curl -fsSLo ${pname}.tar.gz "https://www.princexml.com/download/prince-${version}-linux-generic-x86_64.tar.gz"',
'tar -zxvf ${pname}.tar.gz ${pname}',
'chmod +x ${pname}'
]

[start]
runImage = 'ubuntu:20.04'
cmd = './${pname} 2>&1'
# https://nixpacks.com/docs/configuration/file

[variables]
pname = 'princexml'
version = '15.1'

[phases.setup]
nixPkgs = ['...', 'corefonts', 'fontconfig', 'glibc']

[phases.princexml]
dependsOn = ['setup'] # make sure this phase runs after the default 'setup' phase
cmds = [
'curl -fsSLo ${pname}.tar.gz "https://www.princexml.com/download/prince-${version}-linux-generic-x86_64.tar.gz"',
'tar -zxvf ${pname}.tar.gz ${pname}',
'chmod +x ${pname}'
]

[start]
runImage = 'ubuntu:20.04'
cmd = './${pname} 2>&1'
I don't see it on my screen do you
Brody
Brodyā€¢14mo ago
you just sent it again, so yes
GetPsyched
GetPsychedOPā€¢14mo ago
No description
GetPsyched
GetPsychedOPā€¢14mo ago
weird.
Brody
Brodyā€¢14mo ago
full logs please also whats with the runimage and cmd?
GetPsyched
GetPsychedOPā€¢14mo ago
Oh, there is no princexml subfolder in the tar.gz unsure. It's residue from caddy :P
Brody
Brodyā€¢14mo ago
delete the start phase also in your princexml phase you may want to copy the resulting binary file into maybe /bin or /usr/bin since your code prob expects it in path?
GetPsyched
GetPsychedOPā€¢14mo ago
yeah so there is ...tar.gz/foo/install.sh that I want to run (it does the binary stuff) where do I put it? [phases.install]?
Brody
Brodyā€¢14mo ago
run it in the same phase
GetPsyched
GetPsychedOPā€¢14mo ago
Okay, and the path would just be /bin?
Brody
Brodyā€¢14mo ago
no, the PATH would be a bunch of different locations https://utilities.up.railway.app/env-vars?prefix=PATH
GetPsyched
GetPsychedOPā€¢14mo ago
not the PATH for prince the PATH for the binary file wait that's the same thing ah so how do I refer to this env? or do I have to copy paste/
Brody
Brodyā€¢14mo ago
you dont need to, its just an example?
GetPsyched
GetPsychedOPā€¢14mo ago
I see
GetPsyched
GetPsychedOPā€¢14mo ago
weird.
No description
GetPsyched
GetPsychedOPā€¢14mo ago
idt it threw a 404 before I copy pasted that URL, replacing ${version} and it works no problem wonder why Railway throws a 404 probably a substitution error Oh I can't reference variables in other variables?
[variables]
pname = 'princexml'
version = '15.1'
full_name = 'prince-${version}-linux-generic-x86_64'
[variables]
pname = 'princexml'
version = '15.1'
full_name = 'prince-${version}-linux-generic-x86_64'
I had done this
Brody
Brodyā€¢14mo ago
no you cant
GetPsyched
GetPsychedOPā€¢14mo ago
yeah realised now hmm so the build works but this error came back If the build failed, then I likely need to tell the lib where the binary is where is it? šŸ’€
Brody
Brodyā€¢14mo ago
did you put the binary in /bin ?
GetPsyched
GetPsychedOPā€¢14mo ago
updated toml:
# https://nixpacks.com/docs/configuration/file

[variables]
pname = 'princexml'
full_name = 'prince-15.1-linux-generic-x86_64'

[phases.setup]
nixPkgs = ['...', 'corefonts', 'fontconfig', 'glibc']

[phases.princexml]
dependsOn = ['setup']
cmds = [
'curl -fsSLo ${pname}.tar.gz "https://www.princexml.com/download/${full_name}.tar.gz"',
'tar -zxvf ${pname}.tar.gz ${full_name}',
'chmod +x ${full_name}/install.sh',
'./${full_name}/install.sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
]
# https://nixpacks.com/docs/configuration/file

[variables]
pname = 'princexml'
full_name = 'prince-15.1-linux-generic-x86_64'

[phases.setup]
nixPkgs = ['...', 'corefonts', 'fontconfig', 'glibc']

[phases.princexml]
dependsOn = ['setup']
cmds = [
'curl -fsSLo ${pname}.tar.gz "https://www.princexml.com/download/${full_name}.tar.gz"',
'tar -zxvf ${pname}.tar.gz ${full_name}',
'chmod +x ${full_name}/install.sh',
'./${full_name}/install.sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
]
Brody
Brodyā€¢14mo ago
bruh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin?????
GetPsyched
GetPsychedOPā€¢14mo ago
hehe it can choose
Brody
Brodyā€¢14mo ago
not how it works
GetPsyched
GetPsychedOPā€¢14mo ago
that's valid bash, though okay okay, so I do this? './${full_name}/install.sh /bin'
Brody
Brodyā€¢14mo ago
does it even need a path
GetPsyched
GetPsychedOPā€¢14mo ago
yes
Brody
Brodyā€¢14mo ago
it can decide itself
GetPsyched
GetPsychedOPā€¢14mo ago
base=$( dirname "$0" )

cd "$base" || exit 1
base=$( dirname "$0" )

cd "$base" || exit 1
this is a line inside install.sh
Brody
Brodyā€¢14mo ago
Press Enter to accept the default directory or enter an alternative
GetPsyched
GetPsychedOPā€¢14mo ago
wait then what is this
Brody
Brodyā€¢14mo ago
current dir
GetPsyched
GetPsychedOPā€¢14mo ago
I see
Brody
Brodyā€¢14mo ago
did you write this?
GetPsyched
GetPsychedOPā€¢14mo ago
yes a long while back
Brody
Brodyā€¢14mo ago
who wrote this then
GetPsyched
GetPsychedOPā€¢14mo ago
also me
Brody
Brodyā€¢14mo ago
šŸ¤Ø
GetPsyched
GetPsychedOPā€¢14mo ago
what are you raising brows for It's 3 AM, I'm not usually this stupid okay now I didn't pass a path what's the "default" since I need to tell that to my application it still doesn't find the binary at whatever the default is
Brody
Brodyā€¢14mo ago
looks like /usr/local/bin and that should be in PATH
GetPsyched
GetPsychedOPā€¢14mo ago
there is an option in node-prince (the npm lib) for setting the binary but that might break local builds unless I remove it locally and keep it in prod
Brody
Brodyā€¢14mo ago
do you see the Installation complete. message in your build logs
GetPsyched
GetPsychedOPā€¢14mo ago
yes
No description
GetPsyched
GetPsychedOPā€¢14mo ago
so it is in /usr/local thonk the prefix so /usr/local/bin hmm
Brody
Brodyā€¢14mo ago
should be and that also should be in PATH, so the npm package should look in PATH automatically
GetPsyched
GetPsychedOPā€¢14mo ago
here's what the docs for the package say:
Prince#binary(binary): Prince: set the path to the prince(1) binary. By default it is prince (in case PrinceXML was found globally installed at the Node API installation time) or the path to the prince binary of the locally installed PrinceXML distribution (in case PrinceXML was not found globally installed at the Node API installation time). This returns the Prince API for further method chaining.
Prince#binary(binary): Prince: set the path to the prince(1) binary. By default it is prince (in case PrinceXML was found globally installed at the Node API installation time) or the path to the prince binary of the locally installed PrinceXML distribution (in case PrinceXML was not found globally installed at the Node API installation time). This returns the Prince API for further method chaining.
there is also:
Prince#prefix(prefix): Prince: set the path to the PrinceXML installation. This by default is either empty (in case PrinceXML was found globally installed at the Node API installation time) or the path to the locally installed PrinceXML distribution (in case PrinceXML was not found globally installed at the Node API installation time). This returns the Prince API for further method chaining.
Prince#prefix(prefix): Prince: set the path to the PrinceXML installation. This by default is either empty (in case PrinceXML was found globally installed at the Node API installation time) or the path to the locally installed PrinceXML distribution (in case PrinceXML was not found globally installed at the Node API installation time). This returns the Prince API for further method chaining.
ref: https://www.npmjs.com/package/prince
Brody
Brodyā€¢14mo ago
it can download prince for you? why havent you used that?
GetPsyched
GetPsychedOPā€¢14mo ago
there is nothing to use? it doesn't specify anything I'm supposed to do to install prince automatically
Brody
Brodyā€¢14mo ago
read their docs?
GetPsyched
GetPsychedOPā€¢14mo ago
they don't have docs IIRC
Brody
Brodyā€¢14mo ago
read the source code?
GetPsyched
GetPsychedOPā€¢14mo ago
this readme is all they have lol ok Should be this https://github.com/rse/node-prince/blob/master/prince-npm.js#L292-L300
Brody
Brodyā€¢14mo ago
but how do you run the download
GetPsyched
GetPsychedOPā€¢14mo ago
as it says here:
in case PrinceXML was not found globally installed at the Node API installation time
so likely the download is automatically done at "Node API installation time"? I found nothing regarding this in my build logs
Brody
Brodyā€¢14mo ago
so then are you trying to overwrite the location in your code?
GetPsyched
GetPsychedOPā€¢14mo ago
yes, to wherever it was installed using ./install.sh
Brody
Brodyā€¢14mo ago
the package should find it automatically since it installs it into a folder in PATH
GetPsyched
GetPsychedOPā€¢14mo ago
but it doesn't (ā•ÆĀ°ā–”Ā°)ā•Æļøµ ā”»ā”ā”»
Brody
Brodyā€¢14mo ago
sounds like something is misconfigured
Brody
Brodyā€¢14mo ago
then specify /bin as the install path
GetPsyched
GetPsychedOPā€¢14mo ago
why so? I wasn't asking why should I specify /bin in the install path I was asking why /bin specifically This is an issue upstream. It can't detect NixOS as a Linux distribution Being punished for being curious oof
Want results from more Discord servers?
Add your server