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
Percy17mo ago
Project ID: af744a5e-c6be-4615-b596-ecda25dd13ea
gridonyx
gridonyx17mo 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
iknowhtml17mo ago
Ah, makes sense. I'll try that out and let you know if that resolves my issue. Thank you!
Brody
Brody17mo ago
you can also specify nixPkgs in the railway.json file, this way you won't need two config files
gridonyx
gridonyx17mo ago
Oh nice, I'll keep note of that for myself PepoG
iknowhtml
iknowhtml17mo 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
Brody17mo 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
iknowhtml17mo 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
Brody17mo ago
can you share your repo so I can get a better idea of what's going on?
iknowhtml
iknowhtml17mo ago
It's a private repo. Is it possible to add you as a collaborator?
Brody
Brody17mo ago
for sure brody192
iknowhtml
iknowhtml17mo ago
Invite sent!
Brody
Brody17mo ago
that's a very peculiar repo you have there
iknowhtml
iknowhtml17mo 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
Brody17mo ago
as a go dev, I've never seen someone mix node and go in such a way
iknowhtml
iknowhtml17mo 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
Brody17mo ago
do you use vscode?
iknowhtml
iknowhtml17mo ago
Yes, I do!
Brody
Brody17mo ago
is it telling you that that file is valid?
iknowhtml
iknowhtml17mo ago
Looks like it is
Brody
Brody17mo ago
use a setup phase instead also remove the 3 dots from the providers array
iknowhtml
iknowhtml17mo ago
So like this?
Brody
Brody17mo ago
looks good to me
iknowhtml
iknowhtml17mo ago
Cool! Let me push and see if it works
Brody
Brody17mo ago
but I've never done a turbo/mono repo, or mixed node and go so I'm not too sure
iknowhtml
iknowhtml17mo ago
Also, it looks like you can specify the location of the Railway configuration file:
Brody
Brody17mo ago
indeed
iknowhtml
iknowhtml17mo ago
I haven't either, this is my first time doing this haha
Brody
Brody17mo 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
iknowhtml17mo ago
Yeah, I have the root directory set to / and the configuration path as /ui/railway.json
Brody
Brody17mo ago
that doesn't seem correct
iknowhtml
iknowhtml17mo ago
Oh, why do you say that?
Brody
Brody17mo ago
just seems wrong lol
iknowhtml
iknowhtml17mo ago
Also, I'm getting these build errors
Brody
Brody17mo 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
iknowhtml17mo ago
LOL, @gridonyx, you did me dirty 😭
Brody
Brody17mo ago
anyway, i how to go mow the lawn before it rains, ill be back later i wish you good luck!
iknowhtml
iknowhtml17mo ago
All good, found useful documentation here: https://nixpacks.com/docs/providers/node
Node | Nixpacks
App source + Nix packages + Docker = Image
iknowhtml
iknowhtml17mo ago
I'll play around with it. Thanks @Brody!
iknowhtml
iknowhtml17mo ago
Oof, good on you sir, this would give me a headache to read 🙀
gridonyx
gridonyx17mo 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
iknowhtml17mo 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
Brody17mo ago
any luck?
iknowhtml
iknowhtml17mo ago
Having trouble with the build command...I can't even run node 🫠
iknowhtml
iknowhtml17mo ago
Brody
Brody17mo ago
how many total services are in this repo
iknowhtml
iknowhtml17mo ago
2
Brody
Brody17mo ago
and what folders are they located in
iknowhtml
iknowhtml17mo ago
ui & api for the front end and back end respectively
Brody
Brody17mo ago
whats contracts for
iknowhtml
iknowhtml17mo ago
Those are smart contracts that'll be deployed to Fuji Testnet on Avalanche
Brody
Brody17mo ago
okay not applicable here
iknowhtml
iknowhtml17mo 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
Brody17mo 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
iknowhtml17mo ago
Yes, bc that's a private package internal to our company 🥲
Brody
Brody17mo ago
well that makes it hard for me to test lol
iknowhtml
iknowhtml17mo ago
Yeah 😅 Let me create a minimal reproducible set up
Brody
Brody17mo ago
do you need to do anything with the go app before starting the ui app that would be awsome
iknowhtml
iknowhtml17mo ago
I could also set up a VSCode live share and give you access to my terminal Which would be quicker
Brody
Brody17mo ago
id kinda need access to railway too, so minimal repo would be best ?
iknowhtml
iknowhtml17mo ago
kk, I'll create a minimal repo Give me a second!
Brody
Brody17mo ago
pls answer question lol
iknowhtml
iknowhtml17mo 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
Brody17mo ago
you sure have massively over complicated this
iknowhtml
iknowhtml17mo 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
Brody17mo 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
iknowhtml17mo 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
Brody17mo ago
well it is a docker container lol i dont see how those commands generate a swagger.json file?
iknowhtml
iknowhtml17mo ago
iknowhtml
iknowhtml17mo ago
pnpm i runs preinstall & postinstall
Brody
Brody17mo ago
what triggers those to run
iknowhtml
iknowhtml17mo ago
Running pnpm i It's NPM non-sense lol
Brody
Brody17mo ago
ah cool i will run those exact commands loaclly
iknowhtml
iknowhtml17mo 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
Brody17mo ago
yes i am idealy you set your app up so it can run whereever
iknowhtml
iknowhtml17mo ago
Ideally, but I didn't 🫠
Brody
Brody17mo ago
didnt do a lot of things lol
iknowhtml
iknowhtml17mo ago
You're not running into any issue using Windows tho are you?
Brody
Brody17mo ago
downloading is slow as hell who ever said pnpm was faster
iknowhtml
iknowhtml17mo ago
It's fast on fully maxed out Macbook Pro 🤣
Brody
Brody17mo ago
'sh' is not recognized as an internal or external command, │ operable program or batch file. makes sense i can convert
iknowhtml
iknowhtml17mo ago
Sounds good! Appreciate it 🙂
Brody
Brody17mo ago
converting your funky scripts to bat too confusing https://test-service1.up.railway.app/ lol
iknowhtml
iknowhtml17mo ago
Wait, so what did you change to get it deployed?
iknowhtml
iknowhtml17mo ago
So it needed gcc??? That's really random lol
Brody
Brody17mo ago
go wanted it for some reason
iknowhtml
iknowhtml17mo ago
Oh, it's also not using providers Fascinating.
Brody
Brody17mo 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
iknowhtml17mo 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
Brody17mo ago
I'd call this more of a "mushy environment"
iknowhtml
iknowhtml17mo ago
lol, it is quite a mess 🥲
Brody
Brody17mo ago
I could have sworn there's a swagger package for node
iknowhtml
iknowhtml17mo ago
Maybe "spaghetti environment" is a more accurate description 🤣 Can it analyze Go code and produce a swagger.json?
Brody
Brody17mo 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
iknowhtml17mo 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
Brody17mo ago
there was an attempt at least
iknowhtml
iknowhtml17mo 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
Brody17mo ago
you know go has an official docker image right? you're installing go into the node layer
iknowhtml
iknowhtml17mo 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
Brody17mo ago
and railway will automatically build with a Dockerfile if it finds one present
iknowhtml
iknowhtml17mo ago
I'll try Docker if I can't figure this out Why is the platform merging my configuration?
Brody
Brody17mo ago
have you gotten my config file to work?
iknowhtml
iknowhtml17mo ago
iknowhtml
iknowhtml17mo ago
No, it doesn't work 😿 But I swear it has something to do with providers
Brody
Brody17mo 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
iknowhtml17mo ago
I'm going to delete the service and re-create it. Something funky is definitely happening
Brody
Brody17mo ago
Brody
Brody17mo ago
haha
iknowhtml
iknowhtml17mo ago
"Turn it off and on" Honestly works every time 😂
Brody
Brody17mo ago
true
iknowhtml
iknowhtml17mo ago
IT WORKED. What an ordeal ☠️ Thank you so much for your help @Brody, you're awesome 🫰🥹
Brody
Brody17mo ago
no problem, sorry I took so long to get you a config file lol
Want results from more Discord servers?
Add your server