R
Railway•3y ago
guess_wh0

Rust Project fails building-stage

See attached textfiles. I have no Idea what to do about this.
47 Replies
jr
jr•3y ago
Can you try setting the variables
NIXPACKS_APT_PACKAGES=libpq-dev
NIXPACKS_NO_MUSL=1
NIXPACKS_APT_PACKAGES=libpq-dev
NIXPACKS_NO_MUSL=1
guess_wh0
guess_wh0OP•3y ago
I tried and it failed in a similar way:
#13 71.35 Compiling ts-rs v6.2.0

#13 71.89 Compiling voteon_date v0.1.0 (/app)

#13 88.66 error: linking with `cc` failed: exit status: 1
#13 88.66 |
#13 88.66 = note: "cc" "-m64" "/tmp/rustcMkmZT0/symbols.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.0.rcgu.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.1.rcgu.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.10.rcgu.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.11.rcgu.o" "/app/target/release/deps/voteon_date- ..................
....................
....................
....................
..................../x86_64-unknown-linux-gnu/lib" "-o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
#13 88.66 = note: /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: cannot find -lpq: No such file or directory
#13 88.66 collect2: error: ld returned 1 exit status
#13 88.66
#13 88.66
#13 88.69 error: could not compile `voteon_date` due to previous error
#13 ERROR: executor failed running [/bin/bash -ol pipefail -c cargo build --release]: exit code: 101
-----
> [stage-0 9/10] RUN --mount=type=cache,id=s/b69c122a-cd54-41d7-98cd-238622931905-/root/cargo/git,target=/root/.cargo/git --mount=type=cache,id=s/b69c122a-cd54-41d7-98cd-238622931905-/root/cargo/registry,target=/root/.cargo/registry --mount=type=cache,id=s/b69c122a-cd54-41d7-98cd-238622931905-target,target=target cargo build --release:
-----

executor failed running [/bin/bash -ol pipefail -c cargo build --release]: exit code: 101

Error: Docker build failed
#13 71.35 Compiling ts-rs v6.2.0

#13 71.89 Compiling voteon_date v0.1.0 (/app)

#13 88.66 error: linking with `cc` failed: exit status: 1
#13 88.66 |
#13 88.66 = note: "cc" "-m64" "/tmp/rustcMkmZT0/symbols.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.0.rcgu.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.1.rcgu.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.10.rcgu.o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152.voteon_date.5c082e5b-cgu.11.rcgu.o" "/app/target/release/deps/voteon_date- ..................
....................
....................
....................
..................../x86_64-unknown-linux-gnu/lib" "-o" "/app/target/release/deps/voteon_date-f9ce41ae41d90152" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
#13 88.66 = note: /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: cannot find -lpq: No such file or directory
#13 88.66 collect2: error: ld returned 1 exit status
#13 88.66
#13 88.66
#13 88.69 error: could not compile `voteon_date` due to previous error
#13 ERROR: executor failed running [/bin/bash -ol pipefail -c cargo build --release]: exit code: 101
-----
> [stage-0 9/10] RUN --mount=type=cache,id=s/b69c122a-cd54-41d7-98cd-238622931905-/root/cargo/git,target=/root/.cargo/git --mount=type=cache,id=s/b69c122a-cd54-41d7-98cd-238622931905-/root/cargo/registry,target=/root/.cargo/registry --mount=type=cache,id=s/b69c122a-cd54-41d7-98cd-238622931905-target,target=target cargo build --release:
-----

executor failed running [/bin/bash -ol pipefail -c cargo build --release]: exit code: 101

Error: Docker build failed
jr
jr•3y ago
Can you share the project id
guess_wh0
guess_wh0OP•3y ago
Is the project id the same thing as the service-name?
jr
jr•3y ago
Just a url to the deployment will work
guess_wh0
guess_wh0OP•3y ago
voteondate-production.up.railway.app
jr
jr•3y ago
I mean the link to the railway deployment. Where the logs are
guess_wh0
guess_wh0OP•3y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
jr
jr•3y ago
Oh appologizes. It should be this variable instead NIXPACKS_APT_PKGS
jr
jr•3y ago
Configuration | Nixpacks
App source + Nix packages + Docker = Image
guess_wh0
guess_wh0OP•3y ago
Instead of NIXPACKS_APT_PACKAGES? Should I also set it to "libpq-dev"?
jr
jr•3y ago
Yup
guess_wh0
guess_wh0OP•3y ago
Okay, brb Same error, unfortunately.
guess_wh0
guess_wh0OP•3y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
guess_wh0
guess_wh0OP•3y ago
I'm new to railway, so this might very well be an issue with my setup.
jr
jr•3y ago
No this is indeed an issue with us. The problem is that the postgres binaries are not available at build time. I think I have the configuration you need though. Can you set the variables to
NIXPACKS_PKGS=postgresql
NIXPACKS_NO_MUSL=1
NIXPACKS_PKGS=postgresql
NIXPACKS_NO_MUSL=1
(so just replacing the apt variable to the pkgs one)
guess_wh0
guess_wh0OP•3y ago
Will try it out!
jr
jr•3y ago
Hmm I see it is the same error
guess_wh0
guess_wh0OP•3y ago
Yup
jr
jr•3y ago
What does your Cargo.toml look like?
guess_wh0
guess_wh0OP•3y ago
[package]
edition = "2021"
name = "voteon_date"
version = "0.1.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = { version = "0.4.19", features = ["serde"] }
diesel = { version = "1.4.8", features = ["postgres", "chrono", "serde_json"] }
diesel_migrations = "1.4.0"
dotenv = "0.15.0"
rand = "0.8.5"
serde = { version = "^1.0", features = ["derive"] }
ts-rs = { version = "6.2.0", features = ["chrono-impl", "format"] }
validator = { version = "0.15", features = ["derive"] }
# sentry = "0.25.0"


# Dependencies used when creating swagger-documentation
rocket_okapi = { version = "0.8.0-rc.2", features = [
"swagger",
"rocket_dyn_templates",
] }
schemars = { version = "0.8.10", features = ["chrono"] }


# Rocket
rocket = { version = "0.5.0-rc.2", features = ["json"] }

[dependencies.rocket_dyn_templates]
features = ["tera"]
version = "0.1.0-rc.2"

[dependencies.rocket_sync_db_pools]
default-features = false
features = ["diesel_postgres_pool"]
version = "0.1.0-rc.2"
[package]
edition = "2021"
name = "voteon_date"
version = "0.1.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = { version = "0.4.19", features = ["serde"] }
diesel = { version = "1.4.8", features = ["postgres", "chrono", "serde_json"] }
diesel_migrations = "1.4.0"
dotenv = "0.15.0"
rand = "0.8.5"
serde = { version = "^1.0", features = ["derive"] }
ts-rs = { version = "6.2.0", features = ["chrono-impl", "format"] }
validator = { version = "0.15", features = ["derive"] }
# sentry = "0.25.0"


# Dependencies used when creating swagger-documentation
rocket_okapi = { version = "0.8.0-rc.2", features = [
"swagger",
"rocket_dyn_templates",
] }
schemars = { version = "0.8.10", features = ["chrono"] }


# Rocket
rocket = { version = "0.5.0-rc.2", features = ["json"] }

[dependencies.rocket_dyn_templates]
features = ["tera"]
version = "0.1.0-rc.2"

[dependencies.rocket_sync_db_pools]
default-features = false
features = ["diesel_postgres_pool"]
version = "0.1.0-rc.2"
This is the source-code: https://gitlab.com/Glitchy-Tozier/voteon.date
GitLab
Glitchy-Tozier / voteon.date · GitLab
Check when your friends' free time matches!
jr
jr•3y ago
thank you I was just able to deploy that repo no problem so I have a feeling it is your cache. Unfortunatley this experience isn't great on Railway at the moment. Can you creating a new service and deploying to that with the same variables that you have now
guess_wh0
guess_wh0OP•3y ago
Will do. Should I keep the environment variables?
jr
jr•3y ago
Yes keep both of the variables
guess_wh0
guess_wh0OP•3y ago
Nice, it seems to have worked!
jr
jr•3y ago
nice!
guess_wh0
guess_wh0OP•3y ago
Now I just need to figure out the other errors 😅 Anyway, thank you for your amazing help! 🙂
jr
jr•3y ago
Hmm I see that there is an error looking for ../frontend. Since you have set the root directory to backend, that is the only directory that will be available. To work with the root directory the "frontend" should be a subdirectory of the root directory
guess_wh0
guess_wh0OP•3y ago
Regarding folder-structure (there's some other errors too, these are 100% my fault): As you may have seen I have a structure like this:
root
-> backend
-> frontend
root
-> backend
-> frontend
To make the server run I need to first build the frontend via npm install && npm run build. Then I need to run the backend to serve the files that got created in /frontend/build.
guess_wh0
guess_wh0OP•3y ago
All that exists at the moment is the backend-part, which is this block:
guess_wh0
guess_wh0OP•3y ago
Do you have any hints on how to connect another block where I can have the frontend get built?
jr
jr•3y ago
Hm That is a workflow that isn't that well supported yet. Currently only single language projects are supported with Nixpacks unfortunatley. That is something we are actively working on (in fact I will use this repo as a test case). However, you may need a Dockerfile to get support for the Node and Rust environments at the moment
guess_wh0
guess_wh0OP•3y ago
That is unfortunate, I was trying to avoid creating dockerfiles. Do you know any good tutorials on how I may approach building it?
jr
jr•3y ago
I was trying to avoid creating dockerfiles.
I feel the same way :/ Hence why we are building Nixpacks. It is just not 100% there yet
Do you know any good tutorials on how I may approach building it?
We have a wasm example that uses both Rust and node. You can check it out here https://github.com/railwayapp/starters/blob/master/examples/rust-wasm/Dockerfile You should be able to ignore all the wasm-pack stuff. And may want to install a newer version of node (the example uses 14)
guess_wh0
guess_wh0OP•3y ago
Thank you, I'll try to play around with it! Do I have to worry about linking the database or will this keep working?
jr
jr•3y ago
If you want the DATABASE_URL available at build time then you need to have ARG DATABASE_URL somewhere in the Dockerfile. But if it is just needed at runtime then you don't need to do anything. Thank you for your patience on this. This is indeed a use case we want to support!
guess_wh0
guess_wh0OP•3y ago
Hope you eventually get it working! 🙂 Any estimations on when this use-case might get supported?
jr
jr•3y ago
I don't want to make any promises, but optimistically within the next 2 weeks. But again, no promises
guess_wh0
guess_wh0OP•3y ago
Alright, thank you and good luck 🙂
guess_wh0
guess_wh0OP•3y ago
https://railway.app/changelog/2022-09-09#configurable-build-command Does this happen to be the new functionality or are "Configurable Build Command" and "Experimental nixpacks.toml Support" something else?
Railway
Changelog #0098
Better Free Plan, Configurable Build Command, nixpacks.toml Support, and Better Java Support
jr
jr•3y ago
They are slightly different. Nixpacks.toml support will eventually allow for defining multiple languages for a single app, but that has not been implemented yet But it is a step in the right direction
guess_wh0
guess_wh0OP•2y ago
Sorry for bothering you again, but is this feature implemented as of yet? I haven't kept up to date with the change-logs.
Adam
Adam•2y ago
Railway Docs
Config as Code | Railway Docs
Documentation for Railway
Adam
Adam•2y ago
@guess_wh0
guess_wh0
guess_wh0OP•2y ago
Thank you! @Adam So I've finally gotten around to looking at the docs. My initial issue was not being able to use multiple languages for a single app. I wasn't able to find a solution to that issue in the docs. Am I missing something? ^ (this is the workflow I'm going for)
guess_wh0
guess_wh0OP•2y ago
I think what I'm looking for might be this? https://docs.railway.app/deploy/builds#build-providers
Railway Docs
Builds | Railway Docs
Documentation for Railway
Adam
Adam•2y ago
What you're looking for is this: https://nixpacks.com/docs/configuration/file Just set multiple providers
Configuration File Reference | Nixpacks
App source + Nix packages + Docker = Image
Want results from more Discord servers?
Add your server