info More than 3 years have passed since last update.
[Rust] Cargo.toml の dependencies に記載するバージョンの探し方 Last updated at 2019-12-26 Posted at 2019-12-23
結論
直面した問題
reqwest (https://docs.rs/reqwest ) を利用したいが cargo install reqwest
を実行しても失敗する
error: specified package `reqwest v0.9.24` has no binaries
が出力される
対応
なぜerrorになるのか
https://doc.rust-lang.org/cargo/commands/cargo-install.html
This command manages Cargo’s local set of installed binary crates. Only packages which have executable [[bin]] or [[example]] targets can be installed, and all executables are installed into the installation root’s bin folder.
google翻訳 このコマンドは、Cargoのインストール済みバイナリクレートのローカルセットを管理します。実行可能な[[bin]]または[[example]]ターゲットを持つパッケージのみをインストールでき、すべての実行可能ファイルはインストールルートのbinフォルダーにインストールされます。
reqwestはbinターゲットを持つパッケージでないから
npm install
のノリではダメらしい
Cargo.tomlのdependenciesに追記する必要がある
Cargo.toml にどう書くか
crates.ioでの探し方
doc.rsでの探し方
reqwest
でググると https://docs.rs/reqwest/0.10.0-alpha.2/reqwest/
が上位にhitする(2019.12.23現在)
上記ページを開いてもdependenciesにどう書けばいいか載っていない
上画像の赤枠をクリックすると https://docs.rs/crate/{crate名}
に遷移する
左カラムにバージョン一覧( Versions
)があるのでそこから選択してCargo.tomlに書くと利用できる
自分の環境では ~/.cargo/registry/src/github.com-{ハッシュ}/reqwest-0.9.24
にダウンロードされていた
Register as a new user and use Qiita more conveniently
You get articles that match your needs You can efficiently read back useful information You can use dark theme What you can do with signing up