lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

error: failed to run custom build command for `lemmy_utils v0.16.3...

Open JohnnyBackflip opened this issue 2 years ago • 37 comments

I can't build the Project.

I did this: https://join-lemmy.org/docs/en/contributing/local_development.html

It failed @ "cargo run"

cargo run
   Compiling lemmy_utils v0.16.3 (/home/johnnyb/lemmy/lemmy/crates/utils)
   Compiling task-local-extensions v0.1.1
   Compiling diesel v1.4.8
   Compiling tokio-stream v0.1.8
error: failed to run custom build command for `lemmy_utils v0.16.3 (/home/johnnyb/lemmy/lemmy/crates/utils)`

Caused by:
  process didn't exit successfully: `/home/johnnyb/lemmy/lemmy/target/debug/build/lemmy_utils-8fc58a1472ad9f1e/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=translations/email/en.json
  cargo:rerun-if-changed=translations/email/fi.json
  cargo:rerun-if-changed=translations/email/ko.json
  cargo:rerun-if-changed=translations/email/pt.json

  --- stderr
  Error: Fmt(Os { code: 2, kind: NotFound, message: "No such file or directory" })
warning: build failed, waiting for other jobs to finish...
error: build failed

Any Help?

JohnnyBackflip avatar Apr 10 '22 16:04 JohnnyBackflip

git pull --recurse-submodules

or

git submodule update --init --recursive --remote

dessalines avatar Apr 10 '22 18:04 dessalines

git pull --recurse-submodules

or

git submodule update --init --recursive

Fetching submodule crates/utils/translations Already up to date.

Didn't work, same error

edit: https://join-lemmy.org/docs/en/contributing/docker_development.html works tho

JohnnyBackflip avatar Apr 10 '22 18:04 JohnnyBackflip

That uses the same files, so if Docker build works, local build should work as well. Does git status show anything out of date? And does crates/utils/translations/translations/en.json exist?

Nutomic avatar Apr 11 '22 11:04 Nutomic

GIt status:

git status On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean

crates/utils/translations/translations/en.json exists.

JohnnyBackflip avatar Apr 11 '22 16:04 JohnnyBackflip

Its clearly missing otherwise you wouldn't be getting a nosuchfilefound excepotion. Show us the output of

head crates/utils/translations/translations/en.json

dessalines avatar Apr 11 '22 22:04 dessalines

Its clearly missing otherwise you wouldn't be getting a nosuchfilefound excepotion. Show us the output of

head crates/utils/translations/translations/en.json

head crates/utils/translations/translations/en.json { "post": "post", "remove_post": "Remove Post", "no_posts": "No Posts.", "create_a_post": "Create a post", "create_post": "Create Post", "number_of_posts": "{{formattedCount}} Post", "number_of_posts_plural": "{{formattedCount}} Posts", "posts": "Posts", "related_posts": "These posts might be related",

JohnnyBackflip avatar Apr 12 '22 09:04 JohnnyBackflip

Other files mentioned in the error message also exist? Then that error doesnt really make sense. Maybe try a clean build.

Nutomic avatar Apr 12 '22 10:04 Nutomic

IE cargo clean

dessalines avatar Apr 12 '22 17:04 dessalines

IE cargo clean

didn't work, same error after doing cargo run again

Other files mentioned in the error message also exist?

No, that's the only error

Maybe try a clean build.

I can try again tomorrow

thanks for helping

JohnnyBackflip avatar Apr 12 '22 18:04 JohnnyBackflip

I have the same issue and a clean build does not appear to have fixed anything. Maybe this is some missing dependency for translations? It doesn't say what file is missing.

SamWhited avatar Apr 14 '22 14:04 SamWhited

Try these commands:

git submodule init
git submodule update --recursive --remote
cargo run

dessalines avatar Apr 14 '22 16:04 dessalines

Try these commands:

git submodule init
git submodule update --recursive --remote
cargo run

Thanks but this doesn't solve the problem.

JohnnyBackflip avatar Apr 14 '22 16:04 JohnnyBackflip

I can confirm that I already checked out submodules and all the files are there.

SamWhited avatar Apr 14 '22 16:04 SamWhited

The CI would be failing if that wasn't working properly, but I'll test it locally in a new folder.

dessalines avatar Apr 14 '22 16:04 dessalines

This could also be a permissions issue, though I'm just taking a stab in the dark. The error message is the same, IIRC because it doesn't know the difference between a file that doesn't exist and one it doesn't have access to. But again, the error message doesn't list what file it's asking for so the submodule that it's building could be a red herring and this is some dependency that it can't find or similar. Maybe the error message needs to be improved as a starting point?

SamWhited avatar Apr 14 '22 16:04 SamWhited

I just ran those exact three commands on a fresh clone, and everything worked fine. The only thing I can suspect, if the files are there:

  • Old rust version
  • Not running cargo clean
  • Not using --remote when cloning the submodules.

dessalines avatar Apr 14 '22 16:04 dessalines

I'm not sure how permissions could get messed up, unless you cloned the repo with a different user that you added submodules.

dessalines avatar Apr 14 '22 17:04 dessalines

Almost guaranteed its the rust version, or not properly installing rust using rustup. No other explanation for why a cargo run would fail, but a docker build working on the same files passes.

dessalines avatar Apr 14 '22 17:04 dessalines

Please don't close this, it is still affecting two people. We are not lying when we say we ran cargo clean, or when we say that we initialized submodules. Here is an exact session starting from scratch that, on my machine at least, reproduces the issue.

$ git clone [email protected]:LemmyNet/lemmy.git --recursive
Cloning into 'lemmy'...
remote: Enumerating objects: 47566, done.
remote: Counting objects: 100% (3614/3614), done.
remote: Compressing objects: 100% (1973/1973), done.
remote: Total 47566 (delta 2024), reused 2976 (delta 1626), pack-reused 43952
Receiving objects: 100% (47566/47566), 11.65 MiB | 14.29 MiB/s, done.
Resolving deltas: 100% (31957/31957), done.
Submodule 'crates/utils/translations' (https://github.com/LemmyNet/lemmy-translations.git) registered for path 'crates/utils/translations'
Cloning into '/home/sam/Projects/lemmy/crates/utils/translations'...
remote: Enumerating objects: 1848, done.        
remote: Counting objects: 100% (1848/1848), done.        
remote: Compressing objects: 100% (1019/1019), done.        
remote: Total 1848 (delta 1523), reused 1131 (delta 826), pack-reused 0        
Receiving objects: 100% (1848/1848), 463.97 KiB | 7.36 MiB/s, done.
Resolving deltas: 100% (1523/1523), done.
Submodule path 'crates/utils/translations': checked out 'ad40feba4263a850f135946847d3ddd1a890a6e7'
$ cd lemmy
$ cargo build
$ cargo build
   Compiling serde_derive v1.0.136
   Compiling tracing-attributes v0.1.20
   Compiling tokio-macros v1.7.0
   Compiling futures-macro v0.3.21
   Compiling thiserror-impl v1.0.30
   Compiling pin-project-internal v1.0.10
   Compiling async-trait v0.1.53
   Compiling actix-macros v0.2.3
   Compiling html5ever v0.25.2
   Compiling diesel_derives v1.4.1
   Compiling derive_more v0.99.17
   Compiling smart-default v0.6.0
   Compiling strum_macros v0.24.0
   Compiling lemmy_apub_lib_derive v0.16.3 (/home/sam/Projects/lemmy/crates/apub_lib_derive)
   Compiling prost-derive v0.9.0
   Compiling actix_derive v0.6.0
   Compiling async-stream-impl v0.3.3
   Compiling futures-util v0.3.21
   Compiling darling_macro v0.13.1
   Compiling pest_derive v2.1.0
   Compiling pin-project v1.0.10
   Compiling thiserror v1.0.30
   Compiling tracing v0.1.32
   Compiling darling_macro v0.12.4
   Compiling actix-web-codegen v4.0.0
   Compiling async-stream v0.3.3
   Compiling tokio v1.17.0
   Compiling tracing-futures v0.2.5
   Compiling tracing-subscriber v0.3.9
   Compiling darling v0.13.1
   Compiling comrak v0.12.1
   Compiling lemmy_utils v0.16.3 (/home/sam/Projects/lemmy/crates/utils)
error: failed to run custom build command for `lemmy_utils v0.16.3 (/home/sam/Projects/lemmy/crates/utils)`

Caused by:
  process didn't exit successfully: `/home/sam/Projects/lemmy/target/debug/build/lemmy_utils-d93e76ca7f395151/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=translations/email/en.json
  cargo:rerun-if-changed=translations/email/fi.json
  cargo:rerun-if-changed=translations/email/ko.json
  cargo:rerun-if-changed=translations/email/pt.json

  --- stderr
  Error: Fmt(Os { code: 2, kind: NotFound, message: "No such file or directory" })
warning: build failed, waiting for other jobs to finish...
error: build failed

SamWhited avatar Apr 14 '22 17:04 SamWhited

The reason is a wrong Rust version. Some repo is out of date.

Here is how to solve it: Rust must be v 1.60.0

rustc --version

rustc 1.60.0

Do this:

sudo apt update sudo apt upgrade curl https://sh.rustup.rs -sSf | sh

Install it.

Then:

source $HOME/.cargo/env

check your Version again:

rustc --version

now it compiles.

JohnnyBackflip avatar Apr 14 '22 17:04 JohnnyBackflip

Ahh, I see, it looks like Rust on Fedora is 1.59.0. I'm stuck with the default fedora packages for <reasons>, so I won't be able to build since it seems to require a very recent version. Oh well, thanks for all the help.

SamWhited avatar Apr 14 '22 17:04 SamWhited

You're gonna wanna use rustup to install rust.

dessalines avatar Apr 15 '22 04:04 dessalines

I can't, sadly.

SamWhited avatar Apr 17 '22 17:04 SamWhited

weirdly enough, I'm hitting this on nixos with rust 1.61. how weird. Also testing on lemmy 0.16.4 when the submodules are not there I hit a different error

Error: FileRead { file: "translations/email/en.json", source: Os { code: 2, kind: NotFound, message: "No such file or directory" } }

which is clear and correct. But when the submodules are there, I hit

Error: Fmt(Os { code: 2, kind: NotFound, message: "No such file or directory" })

I was wondering what the Fmt in front of the error meant. I discovered it's actually just a missing rustfmt binary. Adding the rustfmt dependency to my build, just fixed it. Just in case anyone comes here again.

happysalada avatar Jun 25 '22 20:06 happysalada

I opened https://github.com/LemmyNet/lemmy/issues/2333 about specifying a minimum supported rust version.

@happysalada There should be no need to install rustfmt for a simple build. Which command did you run to get that second error?

Nutomic avatar Jun 27 '22 10:06 Nutomic

just cargo build you can see the other people in the thread have exactly the same error (it starts with Fmt). Not sure why, but it looks like rustfmt is required here. I don't think it appears on most machines since people have it by default, however, on some build environments with little dependencies this is where we see the error. (I'm coming here from updating lemmy on nixos).

happysalada avatar Jun 27 '22 16:06 happysalada

@happysalada Could you test if a toolchain file can solve the problem for you? I suppose it should look something like this, but not sure which components are really needed.

[toolchain]
channel = "stable"
components = [ "rustfmt", "rustc-dev" ]

It would also be nice to show a better error message in case a user forgot to sync the submodule, but i cant think of any good way to do that.

Nutomic avatar Jun 27 '22 19:06 Nutomic

Depending on the distribution, a toolchain file might not work. On nixos for example, rust doesn't use a toolchain file, you have to pull separately each component manually. Nix won't allow you to download something from the internet without defining how to build it from source or its sha256. I don't know about other distributions. For nixos, we have to add "rustfmt" to the list of build inputs, there is unfortunately no way around it.

happysalada avatar Jun 27 '22 21:06 happysalada

lemmy % cargo build Compiling serde_derive v1.0.137 Compiling tokio-macros v1.7.0 Compiling tracing-attributes v0.1.20 Compiling futures-macro v0.3.21 Compiling thiserror-impl v1.0.31 Compiling actix-macros v0.2.3 Compiling async-trait v0.1.56 Compiling pin-project-internal v1.0.10 Compiling html5ever v0.25.2 Compiling diesel_derives v1.4.1 Compiling derive_more v0.99.17 Compiling openssl-macros v0.1.0 Compiling strum_macros v0.24.0 Compiling smart-default v0.6.0 Compiling activitypub_federation_derive v0.2.0 Compiling actix_derive v0.6.0 Compiling futures-util v0.3.21 Compiling pin-project v1.0.10 Compiling darling_macro v0.13.1 Compiling darling_macro v0.14.1 Compiling thiserror v1.0.31 Compiling pest_derive v2.1.0 Compiling tracing v0.1.34 Compiling tokio v1.18.2 Compiling openssl v0.10.40 Compiling darling_macro v0.12.4 Compiling actix-web-codegen v4.0.0 Compiling darling v0.13.1 Compiling darling v0.14.1 Compiling comrak v0.12.1 Compiling tracing-futures v0.2.5 Compiling tracing-subscriber v0.3.9 Compiling darling v0.12.4 Compiling lemmy_utils v0.16.5 (/Users/medivh/lemmy/crates/utils) Compiling doku-derive v0.11.0 (https://github.com/anixe/doku#10a0339a) error: failed to run custom build command for lemmy_utils v0.16.5 (/Users/medivh/lemmy/crates/utils)

Caused by: process didn't exit successfully: /Users/medivh/lemmy/target/debug/build/lemmy_utils-d071c63e4373867a/build-script-build (exit status: 1) --- stderr Error: FileRead { file: "translations/email/en.json", source: Os { code: 2, kind: NotFound, message: "No such file or directory" } } warning: build failed, waiting for other jobs to finish...

image

medivh63 avatar Jul 29 '22 07:07 medivh63

@medivh63 Did you follow the steps in this comment?

Nutomic avatar Jul 29 '22 08:07 Nutomic