R
Railway•14mo ago
DarthAI

Rust - ERROR [stage-0 3/9] COPY .nixpacks/nixpkgs...

We have successfully managed to run our Rust service locally, and it builds properly on CI in GitHub. However, we recently started using Railway and are facing an error in the deployment. I have tried running 'nixpacks build .' on my local machine but it fails with a similar error. In an attempt to understand what's going on, I added a dummy 'nixpacks.toml' file to the project's root, but it doesn't seem to be getting picked up.
name = "your-project-name"
version = "0.1.0"

[build]
commands = [
"mkdir -p bin",
"cargo build --release --package core-api",
"cp target/release/core-api bin"
]

[start]
commands = [
"./bin/core-api"
]

[dependencies]
nix = "nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix"
name = "your-project-name"
version = "0.1.0"

[build]
commands = [
"mkdir -p bin",
"cargo build --release --package core-api",
"cp target/release/core-api bin"
]

[start]
commands = [
"./bin/core-api"
]

[dependencies]
nix = "nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix"
Can I get some help to understand what the problem is?
No description
No description
27 Replies
Percy
Percy•14mo ago
Project ID: 8811bf1a-27f3-48f9-9c58-440d79085151
DarthAI
DarthAIOP•14mo ago
Project ID: 8811bf1a-27f3-48f9-9c58-440d79085151
Brody
Brody•14mo ago
is that an AI generated nixpacks.toml?
DarthAI
DarthAIOP•14mo ago
yes, I have added that one after the errors and failures. I don't think it's being picked up
Brody
Brody•14mo ago
it's not being picked up because the syntax is completely wrong lmao
DarthAI
DarthAIOP•14mo ago
😄
Brody
Brody•14mo ago
never take what what an AI says at face value take the time to manually read the docs, it will pay off https://nixpacks.com/docs/configuration/file show me your new nixpacks.toml? stop deleting stuff lol
DarthAI
DarthAIOP•14mo ago
my bad
DarthAI
DarthAIOP•14mo ago
Alright, the file is being picked up but back to square one with the errors (attached) Here is my file
[phases.build]
cmds = ['cargo build --release']

[variables]
CARGO_HOME = '/app/.cargo'
RUSTUP_HOME = '/app/.rustup'

[staticAssets]
# Add any static assets here.

[phases.setup]
nixOverlays = ['https://github.com/oxalica/rust-overlay/archive/master.tar.gz']
nixPkgs = ['rustc', 'cargo']

[start]
runImage = 'debian:bullseye-slim'
onlyIncludeFiles = ['./target/release/railway_mento']
[phases.build]
cmds = ['cargo build --release']

[variables]
CARGO_HOME = '/app/.cargo'
RUSTUP_HOME = '/app/.rustup'

[staticAssets]
# Add any static assets here.

[phases.setup]
nixOverlays = ['https://github.com/oxalica/rust-overlay/archive/master.tar.gz']
nixPkgs = ['rustc', 'cargo']

[start]
runImage = 'debian:bullseye-slim'
onlyIncludeFiles = ['./target/release/railway_mento']
Brody
Brody•14mo ago
have you read the documentation for nixpacks?
DarthAI
DarthAIOP•14mo ago
You mean the whole website or the link you shared? If you can share a proper nixpacks.toml file that works for Rust that is really helpful
Brody
Brody•14mo ago
why do you need to use one in the first place?
DarthAI
DarthAIOP•14mo ago
I do not need to, I want to get our rust server code to build on Railway and get deployed It's building and running fine locally and builds fine on Github. Railway uses NixPacks and that's where the errors are coming from
Brody
Brody•14mo ago
try disabling nixpacks cacheing
DarthAI
DarthAIOP•14mo ago
Is that something that I do on Railway?
DarthAI
DarthAIOP•14mo ago
What should be the value for that env var? I'm setting getting the same error with empty and true Deployement ID if you can check 6760beb2-1a61-42d0-887b-c5dd0ee17010
Brody
Brody•14mo ago
it would be any value, i don't work for Railway so I can't check
DarthAI
DarthAIOP•14mo ago
Ah! Thanks for helping me!
Brody
Brody•14mo ago
I think it might be best for you to move to a Dockerfile based build
DarthAI
DarthAIOP•14mo ago
I do have a docker compose file that cobines a bunch of things, that's what we are using locally and on github But NixPacks does not pick it up
Brody
Brody•14mo ago
you seem to have a good understanding of how rust apps are built and ran so throwing together a dockerfile should not be a problem for you railway does not support docker compose files
DarthAI
DarthAIOP•14mo ago
Alright so from your knowledge with Railway can I point it to a dockerfile in the sub folders or it should be at root?
Brody
Brody•14mo ago
if you had your rust app in an /api subfolder for example, you would put the dockerfile in that subfolder and then point the services root directory to that subfolder, and then the dockerfile is automatically picked up
DarthAI
DarthAIOP•14mo ago
Thanks! I'll give that a shot, thanks for helping out lost folks
Brody
Brody•14mo ago
no problem 🙂
jr
jr•14mo ago
You also shouldn't need a nixpacks.toml file to build and deploy rust apps. You can try deleting the file and deploying
Want results from more Discord servers?
Add your server