Unable to update registry with byteorder - rust

I have an error when I execute cargo run. I added the line byteorder = "0.3.13" to my Cargo.toml, and here is the output of cargo run --verbose:
Updating registry `https://github.com/rust-lang/crates.io-index`
Unable to update registry https://github.com/rust-lang/crates.io-index
Caused by:
failed to fetch `https://github.com/rust-lang/crates.io-index`
Caused by:
[9] Object not found - failed to find pack entry (c7c0b5bc32630012be674d1cacd1487d09a2c0b5)
When I remove the line, everything is ok. How do I fix this error?

Fixed ! I just reinstalled rust nightly with multirust :)

Related

How I can fix 'failed to parse the `edition` key' in anchor build command?

I am trying run anchor build but
error: failed to download `anchor-attribute-access-control v0.26.0`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/Users/???/.cargo/registry/src/github.com-1ecc6299db9ec823/anchor-attribute-access-control-0.26.0/Cargo.toml`
Caused by:
failed to parse the `edition` key
Caused by:
this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.
I fix edition but I see the same error for another packages. (for example)
Caused by:
failed to parse manifest at `/Users/???/.cargo/registry/src/github.com-1ecc6299db9ec823/anchor-attribute-account-0.26.0/Cargo.toml`
I guess I can do smth I don't need fix manually each package.
Thanks
PS:
rustup -V:
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.66.1 (90743e729 2023-01-10)`
cargo -V
cargo 1.66.1 (ad779e08b 2023-01-10)
anchor -V
anchor-cli 0.26.0
os: macOS Big Sur 11.6.5

is it possible to use the path when using git to add the dependencies in rust cargo

I want to add the cargo dependencies rocket-okapi as git url, now I added the dependencies like in Cargo.toml this:
rocket-okapi = { git = "https://github.com/GREsau/okapi/tree/master/rocket-okapi"}
but when I build the project using cargo build command ,shows error like this:
$ cargo build
Updating git repository `https://github.com/GREsau/okapi/tree/master/rocket-okapi`
warning: spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34)
warning: spurious network error (1 tries remaining): unexpected http status code: 404; class=Http (34)
error: failed to get `rocket-okapi` as a dependency of package `fortune v0.1.0 (/workspaces/fortune)`
Caused by:
failed to load source for dependency `rocket-okapi`
Caused by:
Unable to update https://github.com/GREsau/okapi/tree/master/rocket-okapi
Caused by:
failed to fetch into: /home/codespace/.cargo/git/db/rocket-okapi-b6c0b0836896ac76
Caused by:
network failure seems to have happened
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
unexpected http status code: 404; class=Http (34)
how to add the sub folder as dependencies in rust cargo? is it possible?
There are a few things here that need a bit of clarification.
When you add a Git dependency to Cargo.toml, it expects a repository. The URL you put in there is a directory in the repository, so cargo freaks out.
Secondly, when a Git dependency is specified, cargo first looks in the repository root for a Cargo.toml file. If it cannot find any, it will search for any Cargo.toml files where the package name is the same as the dependency.
The dependency you specified, rocket-okapi, doesn't exist in the repository, so cargo gives up. Changing the name of the dependency to 'rocket_okapi' fixes this.
TL;DR: Use this
rocket_okapi = { git = "https://github.com/GREsau/okapi" }

cargo version 2021 required on Solana anchor build

I am trying to run anchor build and am receiving the following response:
BPF SDK: /root/.local/share/solana/install/releases/1.8.0/solana-release/bin/sdk/bpf
Running: rustup toolchain list -v
Running: cargo +bpf build --target bpfel-unknown-unknown --release
error: failed to download `solana-frozen-abi v1.9.4`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/root/.cargo/registry/src/github.com-1ecc6299db9ec823/solana-frozen-abi-1.9.4/Cargo.toml`
Caused by:
feature `edition2021` is required
consider adding `cargo-features = ["edition2021"]` to the manifest
PS: I have already tried suggestions at: Unable to specify `edition2021` in order to use unstable packages in Rust
It looks like your solana install is quite out of date. I would install either 1.8.11 or just run solana-install update
At times, also consider downloading to like in my case I had to change from 2021 in my Cargo.toml file to 2018 and this has worked

Cargo error: unable to get packages from source

error: failed to download `adler v1.0.2`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/home/actionanand/.cargo/registry/src/github.com-1ecc6299db9ec823/adler-1.0.2/Cargo.toml`
Caused by:
could not parse input as TOML
Caused by:
unexpected character found: `\u{0}` at line 1 column 1
Rust .toml file was full of red line when we add new dependency
This is caused by the crash of internal package (say cargo)
we can solve this by following the steps
Please clear the cargo registry
rm -rf /home/username/.cargo/registry/
And follow the proceedure shown after this, if you use old version
For the reference, I've given the proceedure also below:
If you are trying to migrate from the previous edition (2018), the
process requires following these steps:
1. Start with `edition = "2018"` in `Cargo.toml`
2. Run `cargo fix --edition`
3. Modify `Cargo.toml` to set `edition = "2021"`
4. Run `cargo build` or `cargo test` to verify the fixes worked
More details may be found at
https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html
You may need to to add --allow-no-vcs sometimes (it'll be prompted by the terminal) as below
cargo fix --edition --allow-no-vcs

Rust: substrate node template build error

I have been following these instructions:
https://substrate.dev/docs/en/knowledgebase/getting-started/
https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup
I get the following error after trying to run this code:
cd substrate-node-template
# NOTE: you should always use the `--release` flag
cargo build --release
# ^^ this will take a while!
This is the error, any idea what's happening?:
Downloaded approx v0.3.2
Downloaded parity-db v0.2.3
error: failed to parse manifest at /Users/ilyssaevans/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-db-0.2.3/Cargo.toml
Caused by:
failed to parse the version requirement `0.11 ` for dependency `parking_lot`
Caused by:
expected comma after minor version number, found '\t'
zsh: command not found: #
run
cargo update -p parity-db
If this doesn't help please clear cargo cache and reinstall

Resources