0

Hope someone can help out here. I'm trying to version self hosted vagrant boxes, so doing this without using Vagrant Cloud.

I've created the following meta data file:

{
  "description": "How about this",
  "name": "Graphite",
  "versions": [
    {
      "version": "1.8",
      "providers": [
        {
          "name": "virtualbox",
          "url": "http://desktopenvironments/Graphite/Graphite_1.8.box"
        }
      ]
    }
  ]
}

This is taken directly from the vagrant (somewhat lacking) documentation found at: http://docs.vagrantup.com/v2/boxes/format.html.

When running a vagrant add (taking the box file that contains this file directly from disk) I get:

The metadata associated with the box 'graphite' appears corrupted.
This is most often caused by a disk issue or system crash. Please
remove the box, re-add it, and try again.

Any assistance as to why this is happening would be greatly appreciated.

BlackSpy
  • 5,563
  • 5
  • 29
  • 38
  • I think you've missed what I'm doing. I've packaged my own box and created a metadata.json file. That file exisits both in the box and in the box stub which is used for versioning. When doing a vagrant add on my self authored box stub I'm getting this error. – BlackSpy May 20 '15 at 12:21

1 Answers1

1

Was generating my metadata file from a c# app I wrote, using UTF8 for text encoding. This is not enough. You need to use UTF8 without BOM. Once the Byte Order Mark was removed it all works 100s.

var settings = new JsonSerializerSettings() { ContractResolver = new LowercaseContractResolver() };
string json = JsonConvert.SerializeObject(metadata, Formatting.None, settings);
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
using (var sink = new StreamWriter(outputFilePath, false, utf8WithoutBom))
{
    sink.Write(json);
}
BlackSpy
  • 5,563
  • 5
  • 29
  • 38