On Mon, 02 Feb 2015 00:37:24 GMT, Tudor Berariu wrote:

I am trying to compile dub from source but I get this error.

$ ./build.sh 
Generating version file...
Running dmd...
source/dub/generators/cmake.d(20): Error: module std.string import 'replace' not found, did you mean 'template Replace(T, U, TList...)'?

It seems the problem is on this line:

import std.string: format, replace;

while there is no replace method in std.string [1] [2].

Am I doing anything wrong here?

[1] https://github.com/D-Programming-Language/phobos/blob/master/std/string.d
[2] http://dlang.org/phobos/std_string.html

I'm going to answer my own question just in case someone else stumbles on this issue also. This error arises when DMD 2.067 (beta) is used. To solve the error I've imported replace from std.array. I changed these imports:

...
import std.array: appender, join;
...
import std.string: format, replace;
...

to

...
import std.array: appender, join, replace;
...
import std.string: format;
...

and the unique usage of replace:

string sanitize(string name)
{
    return name.replace(":", "_");
}

to

...
    return replace(name, ":", "_");
...



There is still a warning to be resolved:

$ ./build.sh 
Generating version file...
Running dmd...
source/dub/generators/cmake.d(97): Warning: use std.algorithm.sort instead of .sort property

which can be removed by changing [on line 97]

...
(info.dependencies ~ info.linkDependencies).dup.sort.uniq.map!sanitize.join(" "),
...

to

...
sort((info.dependencies ~ info.linkDependencies).dup).uniq.map!sanitize.join(" "),
...