3
votes

The Cargo README states the following:

Compiling from Source

Cargo requires the following tools and packages to build:

  • python
  • curl (on Unix)
  • cmake
  • OpenSSL headers (only for Unix, this is the libssl-dev package on ubuntu)
  • cargo and rustc

First, you'll want to check out this repository

git clone --recursive https://github.com/rust-lang/cargo 
cd cargo

With cargo already installed, you can simply run:

cargo build --release

Otherwise, you can also use a more traditional approach:

./configure
make
make install

It indicates that Cargo is a dependency for building Cargo, but also seems to indicate that if Cargo is not installed then the method starting with ./configure should work.

When I clone that repo and run ./configure I get an error

...
configure: found cmake
configure: found make
configure: recreating config.tmp
configure: 
configure: processing ./configure args
configure: 
configure: CFG_PREFIX           := /usr/local 
configure: CFG_LOCAL_RUST_ROOT  :=  
configure: CFG_CARGO            := cargo 
configure: CFG_RUSTC            := rustc 
configure: CFG_RUSTDOC          := rustdoc 
configure: CFG_CARGO            :=  
configure: error: needed, but unable to find any of: CFG_CARGO cargo

Does this mean I can't build Cargo from source without having Cargo installed? Maybe an argument to configure is missing?

I built Rust from source because I am not a privileged user on this system and have the installation in my user directory.

1
You don't need to build Rust or Cargo yourself just because you are not a privileged user. Rustup installs everything to your home directory. - Shepmaster
Well I'll be... - turbulencetoo

1 Answers

1
votes

According to the discussion here Issue 3772:

Indeed yeah Cargo is required to compile Cargo. In future Rust releases we'll have --enable-extended which will compile Cargo as well as Rust.

But some cargo bootstrapping scripts could be found. For example: https://github.com/dhuseby/cargo-bootstrap.