Toolchain version on new package was different from default every time I created project.
Problem
Same as title.
Solution
- Run
rustup show
Default host: x86_64-pc-windows-msvc rustup home: *my rustup home* installed toolchains -------------------- stable-x86_64-pc-windows-msvc (default) 1.42.0-x86_64-pc-windows-msvc active toolchain ---------------- 1.42.0-x86_64-pc-windows-msvc (overridden by *'A path to toolchain file.'*) rustc 1.42.0 (b8cedc004 2020-03-09)
- Delete the overriding toolchain file at
*'A path to toolchain file.'*
.
Comment
Toolchain file overrides toolchain version below the file directory. If you don't need the override, you can delete the file.
日本語
cargo init(あるいはnew)
をしたときにtoolchainのバージョンがdefaultにならないという問題に直面した。
どうやら知らない間にtoolchainのバージョンを指定するファイルが作られていたためにすべてオーバーライドされていた。そのためtoolchainファイルを削除することで解決した。
原因として知らぬ間にcargo compete
を誤ってrootディレクトリで行ったからだと考えている。100%自分の失態。
docker-compose でハマったこと
1. env_fileはserviceごと
2. Dokerfileでビルドするときはファイルのパスではなくディレクトリのパスを渡す
3. sambaのネットワークドライブをマウントしたいときはcifs
# 例(${}は.envで指定する環境です) volumes: nas: driver_opts: type: cifs o: "rw,username=${ENV_SMB_USER},password=${ENV_SMB_PSWD},file_mode=0777,dir_mode=0777" device: "//ip/path"
4. .envで設定した環境がblankと言われたら何かが悪いか、放置して祈ってお願いするとたまに通る
My solution to an error on rust-analyzer extension.
Error Environment
Windows 10 20H2
VS Code
cd $(rustc --print sysroot); cd lib\rustlib\src\rust
=> src
, Cargo.lock
Error
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /*path-to-my-workspace*. Is rust-src installed?: can't load standard library from sysroot /*my-sysroot* (discovered via `rustc --print sysroot`) try installing the Rust source the same way you installed rustc
This solution might be effective to the build failed
error as well.
Solution (at your own risk)
Use latest toolchain.
rustup update rustup default stable
If rustc says override bruh, see also https://shiotomat.hatenablog.com/entry/2022/01/30/135559. You can choose nightly instead.
Rename src
at $(rustc --print sysroot)\lib\rustlib\src\rust
library
, then rust-analyzer works.
I have no idea what will happen after updating rust in the future.
Additional Comment
rustup component add rust-src
arises info: component 'rust-src' is up to date
日本語
toolchainが古いと出るようなのでtoolchainを最新のものにすると動くようになります
rustup update rustup default stable
をします。overrideがなんとかかんとか......と言われた場合、この問題が関係しているかもしれません。
上記エラーが出るときの解決法の一つ。
ls $(rustc --print sysroot)\lib\rustlib\src\rust
を実行したときにsrc
, Cargo.lock
が出てくる人はsrc
をlibrary
に名前を変更すると直ります。
アップデート時に問題が起こるかもしれませんがわからないので自己責任で。
matlabのシンボリックリンクがインストーラで作れなかったので
解決策
はじめからだと
- zipをダウンロード
- unzip
cd "unzipしたフォルダのパス"
./install
- シンボリックリンクを作らずにインストール
cd /usr/loca/bin
ln -s "matlabへのパス" matlab
(ex:/usr/local/R2021b/bin/matlab
)
参考
ファイル実行時に起きたトラブル
面倒は自動化しよう(.sh)
環境
Ubuntu Desktop 20.04.3 LTS
事例
rust で競プロをする際にcargo compete を使っている。しかし使用時に目的のディレクトリに移動、cargo compete new
、vscodeで開くという作業は地味に面倒である。
方策
シェルスクリプトを作成して一連の作業を自動化する。
ディレクトリの構成はこのようになっている。
- root - atcoder - codeforces
rootはcargo compete new
を実行したいディレクトリであり、僕の環境では外付けのSSDのフォルダである。シェルスクリプトの名前はac.sh
とする(auto creation のつもり)。
#!/bin/bash if [ "$2" = "" ]; then echo "error: need contest name." exit 1 fi root="ここにルートディレクトリ" cd $root/$1 && cargo compete new $2 ; cd ./$2 && code .
使い方は
bash /[path]/ac.sh [platform] [コンテスト名]
で~
にac.sh
がおいてあるならば
bash ~/ac.sh atcoder abc200
など。これで作成からvscode起動までやってくれる。
適当なエラー処理で実装したが、コンテスト名が空白だと面倒が起こるためそこの処理はした。
cargo compete new
の後ろが;
になっているのはすでにディレクトリが存在するというエラーが起きたときにもvscodeを開くためである。
エイリアス
毎度bash ac.sh atcoder abcxxx
で実行するのは面倒である。alias で簡略化することでこれを回避する。「Bash環境でエイリアス(alias)の定義をしよう」を参考にした。
恒久的にエイリアスを定義したいから
sudo nano ~/.bashrc
で
alias competeac="bash ~/ac.sh atcoder" alias competecf="bash ~/ac.sh codeforces"
と追記した。追記部分はわかりやすくするために個人的に上の方に書いた。
これによってatcoderであれば
competeac abcxxx
でabcxxxが作られるのである。簡単で素晴らしい。