How to initialise a git repository with libgit2 - c++

On a Windows XP, 32-bit machine I've cloned the libgit2 repository using
git clone git://github.com/libgit2/libgit2.git trunk
Then I configured from trunk_build_debug for mingw using:
cmake ../trunk -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-g
and build-ed it with
make
With this newly build library I'm trying to create a new repository. So I'm using
error_code = git_repository_init( &repo, path, 0 );
if ( error_code != 0 )
{
const git_error * error = giterr_last();
/* the text representation:
( error == NULL || error->message == NULL ?
"(no description)" :
error->message )
*/
}
On first attempt this fails with the error message:
Git error -1: The global file '.config/git/config' doesn't exist: The
system cannot find the file specified.
The .git directory is created and I can use git status to query it. Also, I have git installed in Program Files/git and it works just fine. The file that is mentioned does not exist in user directory, that is true. I'm not happy because I can't check the returned error code (the error may be "real").
So I've created an empty file in D:\Documents and Settings\User Name.config\git\config
The .git directory is again created but I get the same -1 error code. This time giterr_last() returns NULL.
Tracing the code in debugger seems to indicate that the library is not happy with my empty file.
However, I think this indicates that I'm doing something wrong. Is there an initialization method? Do I need to create the file and use the git_config_ functions to point the library to it?
BTW, is this the wrong place to ask this? Is there a dedicated forum where I should ask this question?
Thanks
Here is the back trace where the call fails: pastebin
It seems that the configure file inside .git directory can't be parsed (not shown in in trace is the 'config_parse()' that fails).
I've opened an issue in libgit2.

To create a new repository, one should rather rely on git_repository_init(). For more information, you can peek at the header and the tests.
git_repository_open() should rather be used when the repository already exists.
Is there a dedicated forum where I should ask this question?
It's ok to ask programming related question on StackOverflow. Beside this, some libgit2 developers hang out in the #libgit2 channel on irc.freenode.net. However, when you encounter bugs, it's recommended to submit them to the issue tracker.
Update
There had been some issues in the past with the way the configuration files are being probbed on Windows. Along with some attempts to fix them. See this issue for some background about this.
Beside the complexity of the probbing, some users may want to explictly provide alternate locations for their files. This pull request works this angle.
Considering what you discovered while debugging the libgit2, maybe now would be a good time to open a bug in the issue tracker. Beware that two issues may be at play: the probbing one and and the empty config issue.

Related

How can I solve this error in OMNest 5.5.1?

I get the following error:
Exception occurred executing command line.
Cannot run program "C:/OMNEST-5.5.1/samples/enera/lteAdvanced/enera.exe" (in directory "C:\OMNEST-5.5.1\samples\enera\lte"): CreateProcess error=2, The System cannot find the file.
I already built the project many times. I have tried to make a simplier already given example from omnet just to check if this is working. It is working. But if I copy this example in my Project it also doesn't work, so there is sth wrong with my Project file. But it seems to be correct. I just have one Connection and kept it really really simple. But it doesn't work. I have installed Omnest and inet correctly.
The most likely cause is that the EXE file cannot find the omnet++ dynamic libraries it tries the load. And the most likely reason is that you are trying to execute the executable from a CMD prompt instead of from the shell provided by the mingwenv.cmd script.
Everything you do in OMNeT++ (including starting the simulations) must be run from the mingwenv shell.

stat not returning properly on centos 7?

So I am running a C++ app, built with CMake (not by me). It works fine on other people testing with it, but not found anyone to test on centos7 yet.
The issue seems to arrise at this snippet of code:
struct stat fileStat;
if ( stat( pszFilePath, &fileStat) == -1 )
{
DEBUG_ERR(( "Can't open input dir [%s]\n", pszFilePath ));
return( false );
}
Which is the first part of the ReadFileInfo call here:
time_t dateChange;
DWORD dwSize;
if ( ! CFileList::ReadFileInfo( GetFilePath(), dateChange, dwSize ))
{
DEBUG_ERR(( "Can't get stats info for file '%s'\n", static_cast<LPCTSTR>(GetFilePath()) ));
return false;
}
Now, pszFilePath is many value, a few examples are:
'scripts/sphere_template_vend.scp'
'scripts/sphere_serv_triggers.scp'
The application is owned by root, the whole folder it all sits in is owned by root. The scripts folder is there and has read/write permissions as do all files (all also owned by root)
Running the application triggers both errors in the above code, there is nothing before them that influences anything.
Im not a C++ developer and do not have the tools to compile with debugs for checking the current path and so on, but I see no reason why it throws these errors. The files exist, the files are accessible, no one else seems to have this problem.
I do have cPanel on the server, but it shouldn't be causing any issues as I am using root user and also keeping out of the /home/ directory
Anyone know of any issue this could be because of? I tried with a '/sphere/' prepending the paths but it still has the same issue, it seems the application does not have access to the files (the application oddly reports line errors within the files it says it cannot read, but they do not match, so assuming its not correct).
Issue reported on the Github for the project here: https://github.com/Sphereserver/Source/issues/64
But no one seems to know whats going on

Exe built using pyinstaller on a Django with pylucene app giving JVM error

I am getting an error:
"Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries"
The error arises when I try to execute my exe file.
I have created exe file through pyinstaller on a django application. Application uses pylucine library. I think it may be the issue of error.
How to fix the error?
Since I can't be certain given you've provided very few details here is a shot in the dark to help solve your problem:
First, try removing the jvm.dll file that gets packaged with the pyinstaller -D youmodule.py command (for now work with the directory command rather than -F option). The reason why is here.
With that jvm.dll file gone, you should start seeing the actual error code - and with that the java class or dependency that isn't being loaded.
If it's a java class that isn't being properly loaded then you know instantly it must not be correcly represented in the classpath environment variable and you should do everything in your power to make sure it is:
e.g.: os.environ['CLASSPATH'] += 'the/path/to/the/jar'
Otherwise, consider bulking up your question with more details, especially if you can get a more meaningful error output.
I had the same error trying to run a .exe built with PyInstaller through wine.
My problem went away by adding C:\Program Files\Java\ [your jdk version here] \jre\bin\server to the PATH environment variable in wine - I suppose it might be the same in Windows.
It also reappeared if I tried to build with C:\Program Files\Java\ [your jdk version here] \jre\bin\server in my PATH, so I had to build without it and then append it before running it (I have no explanation as to why this happens).

how to replace the uninstallation part of an MSI

I've build a msi installer using a VS2010 setup project.
Now the project does not deinstall because of a "1001 Exception: Invalid format for argument machineName" (see below) inside a custom action.
I am unsucessful at uninstalling the application using the remove from the system control or msiexec /uninstall.
Is there a way to force uninstallation?
Details:
As part of a custom action I register a custom event source which my app uses for event loging into the windows log:
public override void Install(IDictionary stateSaver) {
base.Install(stateSaver);
EventLog.CreateEventSource("VeodinRecorder","Application");
}
inside of the "Uninstall" I try to remove this Eventsource with
if (!EventLog.SourceExists("VeodinRecorder"))
EventLog.Delete("VeodinRecorder"); `
The EventLog.Delete also takes machinename as second argument
So I tried to overwrite the msi used for uninstallation with msiexec /fv and changed the uninstall action:
EventLog.Delete("VeodinRecorder",".");
EventLog.Delete("VeodinRecorder","Application");
I even left the whole "uninstall action" blank.
But nothing seemed to work.
Any Hints?
The full log:
Error 1001. Error 1001. An exception occurred while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete. --> Invalid format for argument machineName.
MSI (s) (60!68) [22:49:00:101]:
DEBUG: Error 2769: Custom Action _3C1D0358_8969_4B01_B8FA_B6B43F4E9E4C.uninstall did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: _3C1D0358_8969_4B01_B8FA_B6B43F4E9E4C.uninstall, 1,
CustomAction _3C1D0358_8969_4B01_B8FA_B6B43F4E9E4C.uninstall returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 22:49:00: InstallExecute. Return value 3.
Action ended 22:49:00: INSTALL. Return value 3.
It seems that the CustomAction.dll was not updated when I update the installation with msiexec /fv.
I now manually placed the newly build CustomAction.dll (with an empty uninstall override) into the installation folder and was able to uninstall.
Update: (Credits to #pcans) use ORCA to edit the currently installed msi and manually disable the uninstall custom action.
Just for reference I want to add that you can also patch the installed product with a minor upgrade to remove any faulty actions in the uninstall sequence before it gets called. This works because a minor upgrade is a reinstall of the same product, and not an uninstall and a reinstall of a new version (which is a major upgrade). You hence replace the uninstall sequence with a correct one before the erronous one gets run.
Creating the patch is quite complicated though, even with professional tools such as Wise or Installshield, but in certain cases this is the only fix that works to get the package properly uninstalled. A package "in the wild" in a company should be fixed this way.
Finally you can use msizap.exe from Microsoft to unregister a whole faulty package from the Windows Installer database, but this is not good since changes to the system are not rolled back at all and lots of junk is left everywhere. The tool itself also seems a bit shaky at times, sometimes creating new errors that are really difficult to fix. Preferably use it for debugging only.
One further note in this already long reply: a special case is when you run a custom action only during the uninstall sequence, and it then returns a faulty return code - sometimes even if it performed its operations ok. These actions can trigger a very annonying "uninstall only rollback situation". Effectively your uninstall is rolled back when it hits the custom action that was never run during install. This will rollback the uninstall and hence work as an installation - your product is left on the machine. Quite strange.
The bottom line: skip return codes for custom actions that are run during uninstall, use other verification mechanisms to ensure the action succeeded.

Windows Mobile fails to uninstall

Testing my app on some WM Std 6.1 I found out that it fails to uninstall. I receive this error:
“[app] was not completely removed. Do you want to remove it from the list of installed programs?"
Checking my setup.dll I can tell that Uninstall_Init and Uninstall_Exit are being called each time but all the files stays (they are not locked, I’ve checked) and its entry doesn’t disappear from the list of installed apps (whether I choose it to stay or not).
There are really only three possible reasons for this:
Uninstall_Init doesn't return continue.
Uninstall_Exit doesn't return continue.
The installer engine failed.
If you have verified that 1 & 2 then ok then 3 is going to be tough to figure out.
Some problems that I have encounted:
Check the DLL dependencies of your setup DLL and try to remove as many as possible. I've found that dependencies to MSXML can cause problems.
Remove any registry setup in your INF file, move it into your setup dll. I've found this to cause the uninstall to fail randomly on random devices because of this.
What I needed up doing for existing customers is write a uninstall application to remove our application manually if the uninstall worked. If you do need to write a manual unistall you need to do the following:
* Remove all your registry keys
* Remove all your files
* Remove registry key HKLM\Security\AppInstall{app name}
* In WM6.1 you need to remove a database record from the EDB database "SwMgmtMetadataStore" where the SWT_INSTALL_NAME_TAG property equals your {app name}.
Another thing worth investigating is the install log created by the cab install/uninstall process.
You can find this within the \Application Data\Volatile\ directory (usually called setup.log).
Copying this file to your desktop PC and opening it in notepad may provide more clues (such as files in use during uninstall) as to why the uninstall did not succeed.
I had several CAB files that worked perfectly on WM 6.0, but stopped working in WM 6.1.
Turns out it was because either the AppName or the Manufacturer had spaces in. Removing the spaces fixed the CAB files and they now successfully uninstall in WM 6.1!!