Cargo build fails on fresh install

This is my circle.yml before this broke:

machine:
  environment:
    CRATES: cbex

dependencies:
  cache_directories:
    - rust-1.5.0-x86_64-unknown-linux-gnu
    - cbex/target
  pre:
    - >
      if [[ ! -d rust-1.5.0-x86_64-unknown-linux-gnu ]]; then
        wget http://static.rust-lang.org/dist/rust-1.5.0-x86_64-unknown-linux-gnu.tar.gz
        tar xvzf rust-1.5.0-x86_64-unknown-linux-gnu.tar.gz
      fi
    - sudo rust-1.5.0-x86_64-unknown-linux-gnu/install.sh --without=rust-docs
  post:
    - for crate in $CRATES; do ( cd $crate && cargo build --verbose ); done

test:
  override:
    - for crate in $CRATES; do ( cd $crate && cargo test --verbose ); done

The problem is that this fails with:

[23] error authenticating: no auth sock variable

when trying to fetch the cargo index from github. To fix this I implemented a hack, modifying my pre: section as follows:

  pre:
    - >
      if [[ ! -d rust-1.5.0-x86_64-unknown-linux-gnu ]]; then
        wget http://static.rust-lang.org/dist/rust-1.5.0-x86_64-unknown-linux-gnu.tar.gz
        tar xvzf rust-1.5.0-x86_64-unknown-linux-gnu.tar.gz
      fi
    - sudo rust-1.5.0-x86_64-unknown-linux-gnu/install.sh --without=rust-docs
    - git clone --bare https://github.com/rust-lang/crates.io-index.git
    - mkdir ${HOME}/.cargo
    - |
      cat >> ${HOME}/.cargo/config <<EOF
      [registry]
      index = "file://${HOME}/midas/crates.io-index.git"
      EOF

That said this seems like a bug in the docker instance. There should be no problems fetching from a public github repository through cargo build.

1 Like

Hi!

I’ve the same problem since 14days… i don’t know how to solve it.

If you found a solution… let me know! :smile:

The workaround is in the original post.

1 Like

This fails because of https://github.com/rust-lang/cargo/issues/2078

I found a nicer workaround, if you enable ssh-agent and add the key Circle added for Github it also works. Add this to the pre step:

- eval `ssh-agent`
- ssh-add /home/ubuntu/.ssh/id_circleci_github

This doesn’t work because each command prefixed with - runs in its own shell. As such eval $(ssh-agent) does not export anything that ssh-add can use.

Yes, sorry I forgot to update my snippet. I ended up using:

- eval `ssh-agent` && ssh-add /home/ubuntu/.ssh/id_circleci_github && cargo test
1 Like