D言語のコンパイラdmdがバージョンの衝突で動かなかった
Mac で Homebrew によって D言語のコンパイラ dmd を導入していたのですが、 brew upgrade をするとなぜか
import std.cstream; import conv: to; int main(){ dout.writeLine(to!(string)(3)); return 0; }
だけの簡単なプログラムすら動かなくなってしまったので結構困っていました。
dmd をコンパイルすると、
/usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1249): Error: template instance std.conv.toImpl!(string, int).toImpl.toStringRadixConvert!(13LU, 10u, true) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, int) Main.d(18): instantiated from here: to!(int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1251): Error: template instance std.conv.toImpl!(string, int).toImpl.toStringRadixConvert!(12LU, 10u, false) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, int) Main.d(18): instantiated from here: to!(int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1253): Error: template instance std.conv.toImpl!(string, int).toImpl.toStringRadixConvert!(8LU, 16u, false) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, int) Main.d(18): instantiated from here: to!(int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1255): Error: template instance std.conv.toImpl!(string, int).toImpl.toStringRadixConvert!(32LU, 2u, false) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, int) Main.d(18): instantiated from here: to!(int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1257): Error: template instance std.conv.toImpl!(string, int).toImpl.toStringRadixConvert!(12LU, 8u, false) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, int) Main.d(18): instantiated from here: to!(int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1259): Error: template instance std.conv.toImpl!(string, int).toImpl.toStringRadixConvert!(24LU, 0u, false) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, int) Main.d(18): instantiated from here: to!(int) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(802): Error: no property 'idup' for type 'const(char)[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): Error: template instance std.conv.toImpl!(string, const(char)[]) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3332): instantiated from here: to!(const(char)[]) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3316): instantiated from here: textImpl!(string, string, const(char)[]) /usr/local/Cellar/dmd/2.065.0/import/std/format.d(871): instantiated from here: text!(string, const(char)[]) /usr/local/Cellar/dmd/2.065.0/import/std/bitmanip.d(1542): instantiated from here: FormatSpec!char /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3332): Error: template std.conv.to cannot deduce function from argument types !(string)(int), candidates are: /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(277): std.conv.to(T) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3332): Error: template std.conv.to cannot deduce function from argument types !(string)(int), candidates are: /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(277): std.conv.to(T) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1249): Error: template instance std.conv.toImpl!(string, ubyte).toImpl.toStringRadixConvert!(4LU, 10u, true) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, ubyte) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, ubyte) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3332): instantiated from here: to!(ubyte) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3316): ... (1 instantiations, -v to show) ... /usr/local/Cellar/dmd/2.065.0/import/std/format.d(1152): instantiated from here: text!(string, void*, string, int, string, int, string, char, string, ubyte, string, ubyte, string, bool, string, bool, string, bool, string, bool, string, bool, string, const(char)[], string, const(char)[], string) /usr/local/Cellar/dmd/2.065.0/import/std/bitmanip.d(1542): instantiated from here: FormatSpec!char /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]' /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1251): Error: template instance std.conv.toImpl!(string, ubyte).toImpl.toStringRadixConvert!(3LU, 10u, false) error instantiating /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(821): instantiated from here: toImpl!(string, ubyte) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(282): instantiated from here: toImpl!(string, ubyte) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3332): instantiated from here: to!(ubyte) /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(3316): ... (1 instantiations, -v to show) ... /usr/local/Cellar/dmd/2.065.0/import/std/format.d(1152): instantiated from here: text!(string, void*, string, int, string, int, string, char, string, ubyte, string, ubyte, string, bool, string, bool, string, bool, string, bool, string, bool, string, const(char)[], string, const(char)[], string) /usr/local/Cellar/dmd/2.065.0/import/std/bitmanip.d(1542): instantiated from here: FormatSpec!char /usr/local/Cellar/dmd/2.065.0/import/std/conv.d(1240): Error: no property 'dup' for type 'char[]'
と大量のエラーが出ます。
最初は気づかなかったのですが、バージョンが DMD64 D Compiler v2.066 なのになぜかエラーには2.065と出力されているので、バージョンが衝突しているのかもしれないと気付き、一時的にアンインストールすることにしました。そして
Uninstalling /usr/local/Cellar/dmd/2.066.1... dmd 2.065.0 is still installed. Remove them all with `brew uninstall --force dmd`
2.065.0 がまだインストールされているから次のコマンドで消すことを指示されていたので指示通りに行うことで問題は解決しました。
brew upgrade でもうまくバージョン管理できない場合もあるみたいなので注意する必要があるようです。