RustによるWebアプリケーション開発を読む
WindowsのWSL上で試すことにした。
rustupのインストールを行う。
rustc ver 1.86.0
rustup ver 1.28.1
がインストールされた。
リンカーはgccを利用するとのことなので
sudo apt install gcc
としたがエラーがでた。
sudo apt-get update実行後
再度インストールしたらOK
WindowsにあらかじめVSCODEがインストールしてあったのでRemoto機能からWSLに接続した。
rust-analyzerもWSL上にインストールした。
2.2 Docker Composeを用いたローカルPCでの開発環境
DockerはWindowsにDocker Disktopをインストールしてあったのでそのまま使用。
compose.yamlとDockerfileをhelloworldフォルダに置いてdocker compose up app --buildをWSL上で実行したらエラーが出た。
=> ERROR [app builder 4/4] RUN cargo build --release 0.2s ------ > [app builder 4/4] RUN cargo build --release: 0.173 error: failed to parse manifest at `/app/Cargo.toml` 0.173 0.173 Caused by: 0.173 feature `edition2024` is required 0.173 0.173 The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.78.0 (54d8815d0 2024-03-26)). 0.173 Consider trying a newer version of Cargo (this may require the nightly release). 0.173 See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature. ------ failed to solve: process "/bin/sh -c cargo build --release" did not complete successfully: exit code: 101
WSL上にインストールしたのがrustの最新バージョン1.86でエディションが2024だったため、DockerfileでDLしたrust環境のエディションが2024をサポートしていなかったのようでDokerfileの
FROM rust:1.78-slim-bookworm AS builderを
FROM rust:1.86-slim-bookworm AS builderに書き替えたら
OKとなった。
2.2.3 PostGresSQL,Redisの追加と起動確認
トラブルなくインストールできた。
2.3 タスクランナーcargo-makeの導入
トラブルなくインストールできた。