jacob-carlborg / dvm

A tool to install and manage D compilers
56 stars 11 forks source link

object.Exception ... Failed to execute 'git describe' #46

Open BoQsc opened 5 years ago

BoQsc commented 5 years ago

I just tried to run a project via specifying dvm as dependency using dub, and I've got this error that mentions "Failed to execute 'git describe'"


object.Exception@C:\Users\vaida\AppData\Local\dub\packages\dvm-0.5.0\dvm\tools\generate_version.d(25): Failed to execute
 'git describe'
----------------
0x0040241B
0x00402360
0x0040CF6B
0x0040CEE5
0x0040CD80
0x0040B0C7
0x743B8484 in BaseThreadInitThunk
0x7721302C in RtlValidSecurityDescriptor
0x77212FFA in RtlValidSecurityDescriptor
Command failed with exit code 1: %DC% -run C:\Users\vaida\AppData\Local\dub\packages\dvm-0.5.0\dvm/tools/generate_versio
n.d

C:\Users\vaida\Desktop>

Here is the .d script

#!/usr/bin/env dub
/+ dub.sdl:
    name "notify"
    description "A little web service of mine."
    authors "Peter Parker"
    homepage "http://myproject.example.com"
    license "GPL-2.0"
    dependency "dvm" version="~>0.5.0"

+/

import std.stdio;

// https://github.com/jacob-carlborg/dvm/blob/4856b674f281feb46dd2331de2244f77ab396604/dvm/util/Windows.d

// https://code.dlang.org/packages/dvm
// import dvm.dvm.Exceptions;

// https://code.dlang.org/packages/tango
// import tango.sys.win32.Types;
// import tango.sys.win32.UserGdi;
// import tango.util.Convert;

// https://wiki.dlang.org/D_for_Win32
import core.sys.windows.windows : SendMessageTimeoutW;
import core.sys.windows.windows : GetLastError;
import core.sys.windows.windows : ERROR_SUCCESS;
import core.sys.windows.windows : SMTO_ABORTIFHUNG;
import core.sys.windows.windows : LPARAM;
import core.sys.windows.windows : HWND_BROADCAST;
import core.sys.windows.windows : WM_SETTINGCHANGE;
void main(){
writeln("test");
}

/// For more info, see: http://msdn.microsoft.com/en-us/library/ms725497(VS.85).aspx
void broadcastSettingChange (string settingName, uint timeout=1)
{
    auto result = SendMessageTimeoutW(
        HWND_BROADCAST, WM_SETTINGCHANGE,
        0, cast(LPARAM)(settingName.toString16z()),
        SMTO_ABORTIFHUNG, timeout, null
    );

    if(result == 0)
    {
        auto errCode = GetLastError();

        if (errCode != ERROR_SUCCESS)
            throw new WinAPIException(errCode, "Problem broadcasting WM_SETTINGCHANGE of '" ~ settingName ~ "'", __FILE__, __LINE__);
    }
}

class WinAPIException : DvmException
{
    LONG code;
    string windowsMsg;

    this (LONG code, string msg = "", string file = __FILE__, size_t line = __LINE__)
    {
        this.code = code;

        if(windowsMsg == "")
            windowsMsg = getMessage(code);

        super(msg == "" ? windowsMsg : msg, file, line);
    }
}
jacob-carlborg commented 5 years ago

DVM is currently not intended to be used as a library or a dependency. I'm guessing that Dub does not clone the DVM repository but instead uses the GitHub API to download the code. Therefore it doesn't have a git repository and git describe fails for this reason.

Perhaps I can add a fallback version as a workaround.