RejectedSoftware Forums

Sign up

Can't Get Basic Example to Compile

I just started my first vibe.d project, but I can't get a simple example from the website to compile. I started by using dub init , then changed to the created directory and used dub generate visuald. I opened up package.json and added

"dependencies": {
    "vibe-d": ">=0.7.15"
},
"versions": [
    "VibeCustomMain"
]


I then ran dub upgrade, opened up app.d, and pasted in this:

import vibe.d;

void userInfo(HTTPServerRequest req, HTTPServerResponse res)
{
    auto username = req.params["user"];
    render!("userinfo.jd", username)(res);
}

void addUser(HTTPServerRequest req, HTTPServerResponse res)
{
    res.redirect("/users/"~req.post["user"]);
}

shared static this()
{
auto router = new URLRouter;
router.get("/users/:user", &userInfo);
router.post("/adduser", &addUser);
router.get("*", serveStaticFiles("./public/"));

// To reduce code redundancy, you can also
// use method chaining:
router
    .get("/users/:user", &userInfo)
    .post("/adduser", &addUser);
    .get("*", serveStaticFiles("./public/"));

listenHTTP(new HTTPServerSettings, router);
}

From the vibe.d website. When I tried to compile, however, I got the error:
Error: module d is in file vibe/d.d, which cannot be read.

I tried adding the path to /vibe-d/bin to the Path variable, but it didn't help at all. can anyone suggest a way to get this to compile?

Re: Can't Get Basic Example to Compile

On Mon, 27 May 2013 22:17:55 GMT, Meta wrote:

I just started my first vibe.d project, but I can't get a simple example from the website to compile. I started by using dub init , then changed to the created directory and used dub generate visuald. I opened up package.json and added

"dependencies": {
    "vibe-d": ">=0.7.15"
},
"versions": [
    "VibeCustomMain"
]


I then ran dub upgrade, opened up app.d, and pasted in this:

(...)

I think you just need to regenerate the VisualD solution (which should also automatically fetch dependencies, so no explicit dub upgrade is usually needed). But I'll add a ticket to remember adding a script to the generated project that automatically regenerates itself when package.json is changed, similar to what CMake does.