fvm(flutter version management)で困ること
以下の環境はWindows11, WSL2 ですが、 macOS Ventura でも同様でした。
flutter commands から色が消える
通常flutter doctor
を実行すれば次のように色のついた状態で内容が表示されると思う。
だがこれをfvm 経由で実行すると色が表示されない。
調べたところfvm のissue で次のようなコメントが見つかった。
引用すると、
I did some digging and it looks like all coloring done by flutter (ie. not
pub
, since it is external) passes through this method: https://github.com/flutter/flutter/blob/abecef6ed36565d5d756da3d406555a4e6e70387/packages/flutter_tools/lib/src/base/terminal.dart#L249Which decides whether to color or not based on this:
However
_platform
does not seem to have a way to be overridden. To overcome it you can just replace the getter to always return true and recompile flutter locally:
ということらしい。具体的なワークアラウンドについてもshilangyu さんがスクショを貼ってくれているが、一応自分の方でも書いておく。
※以下は自己責任でお願いします。以下の内容により生じたあらゆる不利益または損害に対して、一切の責任を負いません。
~/fvm/default/packages/flutter_tools/lib/src/base/terminal.dart
を変更
@override bool get supportsColor => true; // bool get supportsColor => _platform.stdoutSupportsAnsi;
rm -dfr ~/fvm/default/bin/cache
を実行
これで再びfvm flutter doctor
を実行すればOK。
OKですね。
shilangyu さんに感謝です。
未解決: fvm flutter run でインタラクティブにデバイス選択ができない
flutter run
を実行するとデバイス選択がシェル上でインタラクティブに可能なのだが、fvm を通すと以下のようにdeviceId を指定しろと言われる。
More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.
これについてもissue が見つかった。
wontfix
タグは削除されているものの、まだ対応はされていない。
職場ではスクリプトを用意してくれた人がいるので従来通りっぽく動かせるのだが、pure なコマンドに比べるといくらか処理速度が遅いのが気になる。 fvm さん対応お願いします。