I am encountering a build error when running cargo build --release on a Substrate Node Template project. Here is the error message:

error: failed to run custom build command for `tikv-jemalloc-sys v0.5.4+5.3.0-patched`
[Error details here...]
configure: error: Prefix should not contain spaces

enter image description here


  • Target: x86_64-unknown-linux-gnu
  • Host: x86_64-unknown-linux-gnu
  • Error occurs during the configuration phase indicating that the prefix should not contain spaces.

Attempted Resolutions:

  • I have tried looking for similar issues and solutions, including checking the tikv-jemalloc-sys repository and Rust community discussions.
  • Checked and ensured environment variables related to the compiler and flags are set correctly.

This project builds successfully on another device, which suggests an environment-specific issue. I suspect it might relate to directory paths or environment settings.


  1. How can I resolve the issue of "Prefix should not contain spaces" in the context of a Rust build using cargo?

  2. Are there any recommended practices for setting paths or environment variables specifically for Rust projects to avoid such issues?

Thank you for your help!

2 Answers 2


I had the exact same issue Prefix should not contain spaces just now and I probably went through the same solutions that you have tried with nothing actually working.

Snippet of part of my error message

So you can see in this screenshot the part where command did not execute successfully, there's my file path which contains white spaces, and I noticed you have too. So I tried running the Substrate Node Template project again on a project folder that has no white spaces on the file path and it actually worked and my build was successful.

I'm not sure if that's the actual solution to this problem but you might want to try and check this assumption based on the successful build on your other device. I would appreciate if you could confirm if it is really the source of this problem.

  • Thank you so much for your answer :) . I resolved it that you explain using the same technique. Thanks again. Commented May 21 at 9:16
  • 1
    Then you could mark this as the answer.
    – AurevoirXavier
    Commented May 21 at 10:18

Try to install: sudo apt install libjemalloc2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.