Start Command Not Working

Service ID: af744a5e-c6be-4615-b596-ecda25dd13ea Configuration: See below & attached screenshot
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "pnpm ui build",
"nixpacksPlan": {
"providers": [
"...",
"go"
]
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "pnpm ui start",
"restartPolicyType": "ALWAYS"
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "pnpm ui build",
"nixpacksPlan": {
"providers": [
"...",
"go"
]
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "pnpm ui start",
"restartPolicyType": "ALWAYS"
}
}
Build is succeeding, but for some reason, I see the following errors in the Deploy Logs:
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
/bin/bash: line 1: pnpm: command not found
Can I get some help on this? Thank you 🙏🙏🙏
114 Replies
Percy
Percy2y ago
Project ID: af744a5e-c6be-4615-b596-ecda25dd13ea
gridonyx
gridonyx2y ago
Since it looks like pnpm is not an available command, in reviewing the nixpacks documentation I believe you need to add a nixpacks.toml to your project repo, and within that include:
[phases.setup]
nixPkgs = ["...", "pnpm"]
[phases.setup]
nixPkgs = ["...", "pnpm"]
iknowhtml
iknowhtmlOP2y ago
Ah, makes sense. I'll try that out and let you know if that resolves my issue. Thank you!
Brody
Brody2y ago
you can also specify nixPkgs in the railway.json file, this way you won't need two config files
gridonyx
gridonyx2y ago
Oh nice, I'll keep note of that for myself PepoG
iknowhtml
iknowhtmlOP2y ago
I have a monorepo set up with different configuration needs for each project. How would I create a railway.json to account for this?
Brody
Brody2y ago
each directoy would need its own railway.json file with the appropriate configurations for that specific app, then just deployed two services and set the root directory appropriately, then railway will use the railway.json in that directory is this a JavaScript frontend with a Go backend?
iknowhtml
iknowhtmlOP2y ago
Yes, it is. The reason why I originally asked how to account for separate configurations is because I need scripts in the root package.json to run as codegen the API client library from a codegened swagger.json in the Go project. But I think it shouldn't be an issue to set the root directory to the ui directory as PNPM will still run the proper scripts from the root package.json, even within a workspace directory. I'll try it out and get back you. Thank @Brody!
Brody
Brody2y ago
can you share your repo so I can get a better idea of what's going on?
iknowhtml
iknowhtmlOP2y ago
It's a private repo. Is it possible to add you as a collaborator?
Brody
Brody2y ago
for sure brody192
iknowhtml
iknowhtmlOP2y ago
Invite sent!
Brody
Brody2y ago
that's a very peculiar repo you have there
iknowhtml
iknowhtmlOP2y ago
lol, yes, it's a dApp we're building for a hackathon, so there's a lot of interesting things happening in there 😅
Brody
Brody2y ago
as a go dev, I've never seen someone mix node and go in such a way
iknowhtml
iknowhtmlOP2y ago
Yeah, it took me a couple days to figure out how to get everything to play nicely together 🫠, but it's a nice DX since I codegen the API & smart contract clients so I don't have to think about typing in the front end 🥹🥹🥹 I'm still struggling to figure out the railway.json file though. Do you mind providing some guidance? Looking at https://backboard.railway.app/railway.schema.json but it's a bit hard to grok since I'm not well versed with JSON schema definitions Does this look right?
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "pnpm ui build",
"nixpacksPlan": {
"providers": [
"...",
"go",
"node"
],
"phases": {
"additionalProperties":{
"nixPkgs": ["pnpm"]
}
}
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "pnpm ui start",
"restartPolicyType": "ALWAYS"
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "pnpm ui build",
"nixpacksPlan": {
"providers": [
"...",
"go",
"node"
],
"phases": {
"additionalProperties":{
"nixPkgs": ["pnpm"]
}
}
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "pnpm ui start",
"restartPolicyType": "ALWAYS"
}
}
Brody
Brody2y ago
do you use vscode?
iknowhtml
iknowhtmlOP2y ago
Yes, I do!
Brody
Brody2y ago
is it telling you that that file is valid?
iknowhtml
iknowhtmlOP2y ago
Looks like it is
Brody
Brody2y ago
use a setup phase instead also remove the 3 dots from the providers array
iknowhtml
iknowhtmlOP2y ago
So like this?
Brody
Brody2y ago
looks good to me
iknowhtml
iknowhtmlOP2y ago
Cool! Let me push and see if it works
Brody
Brody2y ago
but I've never done a turbo/mono repo, or mixed node and go so I'm not too sure
iknowhtml
iknowhtmlOP2y ago
Also, it looks like you can specify the location of the Railway configuration file:
Brody
Brody2y ago
indeed
iknowhtml
iknowhtmlOP2y ago
I haven't either, this is my first time doing this haha
Brody
Brody2y ago
just feel the need to say this.. setting the root directory to /ui and the railway config path to /ui/railway.json would be redundant
iknowhtml
iknowhtmlOP2y ago
Yeah, I have the root directory set to / and the configuration path as /ui/railway.json
Brody
Brody2y ago
that doesn't seem correct
iknowhtml
iknowhtmlOP2y ago
Oh, why do you say that?
Brody
Brody2y ago
just seems wrong lol
iknowhtml
iknowhtmlOP2y ago
Also, I'm getting these build errors
Brody
Brody2y ago
pnpm isnt even a nix package, bro just made it up and we trusted him thats kinda funny tbh railway will install pnpm for you if it detects a pnpm-lock.yaml, so make that happen, then you can remove the pnpm stuff from your railway.json file
iknowhtml
iknowhtmlOP2y ago
LOL, @gridonyx, you did me dirty 😭
Brody
Brody2y ago
anyway, i how to go mow the lawn before it rains, ill be back later i wish you good luck!
iknowhtml
iknowhtmlOP2y ago
All good, found useful documentation here: https://nixpacks.com/docs/providers/node
Node | Nixpacks
App source + Nix packages + Docker = Image
iknowhtml
iknowhtmlOP2y ago
I'll play around with it. Thanks @Brody!
iknowhtml
iknowhtmlOP2y ago
Oof, good on you sir, this would give me a headache to read 🙀
gridonyx
gridonyx2y ago
I was just going based off the nixpacks docs lmao, the only other thing in the docs is to use aptPkgs instead of nixPkgs Apologies for any confusion
iknowhtml
iknowhtmlOP2y ago
All good! You don't need to configure anything for PNPM, per @Brody's message (https://discord.com/channels/713503345364697088/1121523128649142282/1121536675802271816), Nixpack automatically detects it
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Brody
Brody2y ago
any luck?
iknowhtml
iknowhtmlOP2y ago
Having trouble with the build command...I can't even run node 🫠
iknowhtml
iknowhtmlOP2y ago
Brody
Brody2y ago
how many total services are in this repo
iknowhtml
iknowhtmlOP2y ago
2
Brody
Brody2y ago
and what folders are they located in
iknowhtml
iknowhtmlOP2y ago
ui & api for the front end and back end respectively
Brody
Brody2y ago
whats contracts for
iknowhtml
iknowhtmlOP2y ago
Those are smart contracts that'll be deployed to Fuji Testnet on Avalanche
Brody
Brody2y ago
okay not applicable here
iknowhtml
iknowhtmlOP2y ago
Yeah, it's not relevant I got the UI running before is the weird part with the following config:
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "pnpm app build",
"watchPatterns": [
"ui/**"
]
},
"deploy": {
"numReplicas": 1,
"startCommand": "pnpm app start",
"restartPolicyType": "ALWAYS"
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "pnpm app build",
"watchPatterns": [
"ui/**"
]
},
"deploy": {
"numReplicas": 1,
"startCommand": "pnpm app start",
"restartPolicyType": "ALWAYS"
}
}
NOTE: ui used to be called app But bc I needed Go in the build step, I added providers and that's when the deployment stopped working
Brody
Brody2y ago
i keep getting ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/@avalabs/k2-components/-/k2-components-4.10.0-alpha.9.tgz: Not Found
iknowhtml
iknowhtmlOP2y ago
Yes, bc that's a private package internal to our company 🥲
Brody
Brody2y ago
well that makes it hard for me to test lol
iknowhtml
iknowhtmlOP2y ago
Yeah 😅 Let me create a minimal reproducible set up
Brody
Brody2y ago
do you need to do anything with the go app before starting the ui app that would be awsome
iknowhtml
iknowhtmlOP2y ago
I could also set up a VSCode live share and give you access to my terminal Which would be quicker
Brody
Brody2y ago
id kinda need access to railway too, so minimal repo would be best ?
iknowhtml
iknowhtmlOP2y ago
kk, I'll create a minimal repo Give me a second!
Brody
Brody2y ago
pls answer question lol
iknowhtml
iknowhtmlOP2y ago
Ah, sorry, the Go app doesn't need to run to start the UI app, I just need to run a codegen to create a swagger.json file which I need to codegen the API client for the UI But running the codegen to create a swagger.json requires a Go environment as I'm using go-swagger to do it
Brody
Brody2y ago
you sure have massively over complicated this
iknowhtml
iknowhtmlOP2y ago
Yes I did 🥲 https://github.com/iknowhtml/trustus-monorepo/tree/railway-minimal-repo Does this work? Do you want me to set up a separate Railway environment?
Brody
Brody2y ago
so starting from the root directory, give me a list of commands id have to run to generate the swagger.json file, and start the ui (assuming i have npm, pnpm, go, node all installed already)
iknowhtml
iknowhtmlOP2y ago
pnpm i
pnpm ui build
pnpm ui start
pnpm i
pnpm ui build
pnpm ui start
If this were a docker container, that's all you would need to do
Brody
Brody2y ago
well it is a docker container lol i dont see how those commands generate a swagger.json file?
iknowhtml
iknowhtmlOP2y ago
iknowhtml
iknowhtmlOP2y ago
pnpm i runs preinstall & postinstall
Brody
Brody2y ago
what triggers those to run
iknowhtml
iknowhtmlOP2y ago
Running pnpm i It's NPM non-sense lol
Brody
Brody2y ago
ah cool i will run those exact commands loaclly
iknowhtml
iknowhtmlOP2y ago
Yes, let me know if you run into any issues You're not running Windows by chance are you? This set up assumes a unix-like environment
Brody
Brody2y ago
yes i am idealy you set your app up so it can run whereever
iknowhtml
iknowhtmlOP2y ago
Ideally, but I didn't 🫠
Brody
Brody2y ago
didnt do a lot of things lol
iknowhtml
iknowhtmlOP2y ago
You're not running into any issue using Windows tho are you?
Brody
Brody2y ago
downloading is slow as hell who ever said pnpm was faster
iknowhtml
iknowhtmlOP2y ago
It's fast on fully maxed out Macbook Pro 🤣
Brody
Brody2y ago
'sh' is not recognized as an internal or external command, │ operable program or batch file. makes sense i can convert
iknowhtml
iknowhtmlOP2y ago
Sounds good! Appreciate it 🙂
Brody
Brody2y ago
converting your funky scripts to bat too confusing https://test-service1.up.railway.app/ lol
iknowhtml
iknowhtmlOP2y ago
Wait, so what did you change to get it deployed?
iknowhtml
iknowhtmlOP2y ago
So it needed gcc??? That's really random lol
Brody
Brody2y ago
go wanted it for some reason
iknowhtml
iknowhtmlOP2y ago
Oh, it's also not using providers Fascinating.
Brody
Brody2y ago
but, in the railway service, leave root directory, build, and start commands all empty, then just set the config path to ui.railway.json it also installs go as a package instead of a provider, since node is the main thing in use and it only took me two tries to get that config right, I gave up on running it locally honestly, how the hell do you even write documentation for this type of thing
iknowhtml
iknowhtmlOP2y ago
To be fair I have an incredibly specific use case that's probably rare af, but perhaps it could be added to a mixed environments section in the docs?
Brody
Brody2y ago
I'd call this more of a "mushy environment"
iknowhtml
iknowhtmlOP2y ago
lol, it is quite a mess 🥲
Brody
Brody2y ago
I could have sworn there's a swagger package for node
iknowhtml
iknowhtmlOP2y ago
Maybe "spaghetti environment" is a more accurate description 🤣 Can it analyze Go code and produce a swagger.json?
Brody
Brody2y ago
oh, then no also the resulting image is like 1 point something gigabytes not ideal the proper fix for the size would be a custom multi-stage dockerfile, but I'll leave that up to you
iknowhtml
iknowhtmlOP2y ago
I made one of those actually LOL
#
# Build stage
#
FROM node:18.16.0 AS builder

#Update packages
RUN apt update

# Download Go.
RUN wget https://golang.org/dl/go1.20.5.linux-amd64.tar.gz

# Extract the Go archive and remove the archive file
RUN tar -C /usr/local -xzf go1.20.5.linux-amd64.tar.gz \
&& rm go1.20.5.linux-amd64.tar.gz

# Add Go to the PATH
ENV PATH="/usr/local/go/bin:${PATH}"

# Check Go version
RUN go version

# Install `go-swagger`
RUN wget https://github.com/go-swagger/go-swagger/releases/download/v0.30.5/swagger_linux_amd64 -O /usr/local/bin/swagger
RUN chmod +x /usr/local/bin/swagger
RUN swagger version

# Install PNPM
RUN corepack enable && \
corepack prepare [email protected] --activate

WORKDIR /app

COPY . .

ARG NPM_AUTH_TOKEN
ENV NPM_AUTH_TOKEN ${NPM_AUTH_TOKEN}

ARG NPM_AUTH_TOKEN
ENV NPM_AUTH_TOKEN ${NPM_AUTH_TOKEN}

RUN pnpm install

RUN pnpm ui build

#
# Run stage
#
FROM node:18.16.0 as runner

WORKDIR /app/ui

COPY --from=builder /app/ui .

ARG PORT
ENV PORT=${PORT}

EXPOSE ${PORT}

ENTRYPOINT ["pnpm","start"]
#
# Build stage
#
FROM node:18.16.0 AS builder

#Update packages
RUN apt update

# Download Go.
RUN wget https://golang.org/dl/go1.20.5.linux-amd64.tar.gz

# Extract the Go archive and remove the archive file
RUN tar -C /usr/local -xzf go1.20.5.linux-amd64.tar.gz \
&& rm go1.20.5.linux-amd64.tar.gz

# Add Go to the PATH
ENV PATH="/usr/local/go/bin:${PATH}"

# Check Go version
RUN go version

# Install `go-swagger`
RUN wget https://github.com/go-swagger/go-swagger/releases/download/v0.30.5/swagger_linux_amd64 -O /usr/local/bin/swagger
RUN chmod +x /usr/local/bin/swagger
RUN swagger version

# Install PNPM
RUN corepack enable && \
corepack prepare [email protected] --activate

WORKDIR /app

COPY . .

ARG NPM_AUTH_TOKEN
ENV NPM_AUTH_TOKEN ${NPM_AUTH_TOKEN}

ARG NPM_AUTH_TOKEN
ENV NPM_AUTH_TOKEN ${NPM_AUTH_TOKEN}

RUN pnpm install

RUN pnpm ui build

#
# Run stage
#
FROM node:18.16.0 as runner

WORKDIR /app/ui

COPY --from=builder /app/ui .

ARG PORT
ENV PORT=${PORT}

EXPOSE ${PORT}

ENTRYPOINT ["pnpm","start"]
Brody
Brody2y ago
there was an attempt at least
iknowhtml
iknowhtmlOP2y ago
Just didn't want to figure out how to use it on Railway, and also couldn't run the image locally bc I can't build it on ARM, and had to switch to a different platform, but then I can't run that image bc it's not built for ARM 🫠😭
Brody
Brody2y ago
you know go has an official docker image right? you're installing go into the node layer
iknowhtml
iknowhtmlOP2y ago
You know what, that probably would've made more sense lol I am a front end engineer. I have no idea what I'm doing when it comes to this stuff LMAO
Brody
Brody2y ago
and railway will automatically build with a Dockerfile if it finds one present
iknowhtml
iknowhtmlOP2y ago
I'll try Docker if I can't figure this out Why is the platform merging my configuration?
Brody
Brody2y ago
have you gotten my config file to work?
iknowhtml
iknowhtmlOP2y ago
iknowhtml
iknowhtmlOP2y ago
No, it doesn't work 😿 But I swear it has something to do with providers
Brody
Brody2y ago
remove all deploys and put all the service settings back to normal the only non default settings you need to set is the railway config path
iknowhtml
iknowhtmlOP2y ago
I'm going to delete the service and re-create it. Something funky is definitely happening
Brody
Brody2y ago
Brody
Brody2y ago
haha
iknowhtml
iknowhtmlOP2y ago
"Turn it off and on" Honestly works every time 😂
Brody
Brody2y ago
true
iknowhtml
iknowhtmlOP2y ago
IT WORKED. What an ordeal ☠️ Thank you so much for your help @Brody, you're awesome 🫰🥹
Brody
Brody2y ago
no problem, sorry I took so long to get you a config file lol
Want results from more Discord servers?
Add your server