I Am Not Myself


Category Archives: Tools

PowerShell, msysgit 1.7.9 and Permission denied (publickey) Errors

TLDR: Add “$env:home = resolve-path ~” to your PowerShell profile.

I recently updated my work Virtual Machine to the latest release of msysgit 1.7.9 to resolve some issues I was having with global settings not being obeyed. After the installation I noticed that I was no longer able to update repositories from PowerShell. The output I was getting looked something like this:

GIT [dirkdiggler] on [master] (clean) | C:\projects\foo
-> git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

This was unexpected and the first thing I thought of was the recent security issue with GitHub, and maybe my work key needed to be validated. I checked GitHub and everything seemed to be set up correctly. I even went so far as to generate new keys with no success.

Next up, it occurred to me to try connecting via git bash.

dirkdiggler@DIRKDIGGLER-VM /c/projects/foo (master)
$ ssh git@github.com
Hi dirkdiggler! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

Bash seems to be working fine. I then started troubleshooting my connection from PowerShell. I tried testing ssh first with the following command.

GIT [dirkdiggler] on [master] (clean) | C:\projects\foo
-> ssh git@github.com
Permission denied (publickey).

So it looks like the problem was not with git but with establishing an ssh connection to GitHub. I wanted to see exactly what was happening when trying to connect via ssh, so I ran the following command with enables verbose logging of the connection.

GIT [dirkdiggler] on [master] (clean) | C:\projects\foo
-> <b>ssh -v git@github.com</b>
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to github.com [] port 22.
debug1: Connection established.
debug1: identity file /.ssh/identity type -1
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5github2
debug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/identity
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

This output did not give me any immediate ideas on the problem but I thought I might try the same command from git bash. I won’t include the full output here, but I did notice something different right away. Check out the following lines from the output. Compare them to lines 6-8 above.

debug1: identity file /c/Users/MGALFAPAIR/.ssh/identity type -1
debug1: identity file /c/Users/MGALFAPAIR/.ssh/id_rsa type 1
debug1: identity file /c/Users/MGALFAPAIR/.ssh/id_dsa type -1

So it looks like ssh running under PowerShell is looking for my public/private key pair in a different directory than under bash. Doing a quick google search I found that an environment variable named home is used when determining the path to look for keys. I went back to PowerShell and checked for the environment variable like so.

GIT [dirkdiggler] on [master] (clean) | C:\projects\foo
-> Write-Host $env:home

No home variable set. So I set it like so.

GIT [dirkdiggler] on [master] (clean) | C:\projects\foo
-> $env:home = Resolve-Path ~

GIT [dirkdiggler] on [master] (clean) | C:\projects\foo
-> Write-Host $env:home

Running the ssh test again, I am now able to connect. Adding the command to my PowerShell profile sets it automatically every time I start PowerShell resolving the problem completely.

Testing Rendered Output of NancyFx with the Razor View Engine Gotchas

I have been working on a small sample application called SignMeUp. My intention is to practice concepts I am learning while reading Growing Object Oriented Software Guided by Tests. I am using the awesome NancyFx micro-framework my web delivery mechanism and Razor as my view engine.

To start I have the following unit test.

    public class when_visiting_the_root_of_the_site : with_a_browser
        private BrowserResponse response;

        public override void Given()
            Configure(with =>

        public override void When()
            response = subject.Get("/");

        public void it_should_be_successful()

        public void it_should_show_the_signup_form()

I have been beating my head against a problem for a few days (over the course of several 1-2 hour development sessions) that has been baffling me. This test compiles and executes and the first test returns successful. The second test has always failed because the Body collection was always empty. The truly enraging thing is I could fire up the site in IISExpress and see that it worked properly.

After searching the internet high and low, trolling source repositories of example apps and finally breaking down and scouring the NancyFx source I have discovered the root of my problem.

Gotcha #1: When executing end to end tests like this from a test library you need to makes sure that your test assembly has knowledge of your views. The simplest solution for this is to set all your views to “Copy if newer” in the properties dialog in visual studio. The default view location should work from here.

Gotcha #2: Your test assembly needs to reference Nancy.ViewEngines.Razor. If you do not have this reference, Nancy will happily process your request and simply return an empty body. No error, no warning, nothing.

Getting Gilded Rose Under Test

While I was attending the Software Craftsmanship North America conference this year, Ian Davis post a video of himself performing the Gilded Rose Kata. I really enjoyed watching it and wanted to take a stab at it myself. I had a couple hours to kill sitting at O’Hair waiting on my flight so I fired up my environment and took a stab at it.

This video is the result of that session. The video consists of me getting the system under test. I did attempt a refactoring a couple times but kept driving to Ian’s solution because it was to fresh in my head. So I trimmed the solution out of my video and left only the testing. Go watch Ian’s video for a elegant solution to the problem. Do note that there is a signifigant amount of play and experimentation in this video, I am just dorking around.

It took me a while to post this because I originally recorded the session using Camtasia:Mac, which is a horribly broken piece of software. I had to wait until I could get a license for ScreenFlow before acutally producing the video. If you are in the market for software to do this kind of video, go with ScreenFlow.

If you are interested, I am using the Giles auto test runner, Nunit and several Resharper macros in the video. You can find my source on github.

Be sure to watch in HD it makes the text much more readable.

Sqlite Provider for Simple.Data 0.5.6

There is a new provider for Simple.Data available via NuGet that will allow you to consume Sqlite databases. Both in memory and file based database are supported. This initial release has some warts in the API, but is usable. It is currently being used in the NerdBeers project for testing support. I plan to buff out the warts over the next few versions.

Here is a quick video showing how to install, setup and use both file based and in memory sqlite databases.

Be sure to watch full screen or download the original HD source.

Check out the various sources:

Introducing the Coding Solo Cowboy Hat of Shame

While at Agile Open Northwest, someone mentioned the best idea I have ever heard. Their team made a rule that if you were going to code by yourself with out a pairing partner you had to raise your hand and announce “I’m coding alone!” and don the Cowboy Hat of Shame.

This was such a great idea, my team decided to implement our own and here it is. The tiara really makes it work.



Using TeamCity to Maintain a Stack of OSS Tools

One of the more difficult problems with using open source libraries in the .NET space is the incestuous nature of the .NET open source community. NHibernate has a dependency on Castle.Windsor. Castle.MonoRail has a dependency on NHibernate and Castle.Windsor. Fluent NHibernate has a dependency on NHibernate. TopShelf has a dependency on Common.ServiceLocator which if you are using the Castle stack adds a dependency for you on the Windsor provider for Common.ServiceLocator. And rarely do all projects have a dependency on the same version of the assembly you happen to have.

It leads to a serious case of DLL hell and honestly prolly scares off the average .NET developer. Tracking down dependency chains is not a great way to deliver value to your customer. Most developers I know end up maintaining their own builds of their external dependencies based on the trunk versions. We don’t want to wait around for Oren to update Raven to use the latest Castle.Windsor so we can take advantage of that spiffy new CollectionResolver baby!

But I am here to let you know that all is not lost. With a little elbow grease and some planning and forethought, you can overcome the problem. This screen cast show a way to tackle the problem. Bake your third party libraries into your CI process and be happy.

Contributing to Open Source Projects On GitHub For .NET Developers Part 3

Part 3: Forking a Project, Keeping It Up To Date & Basic Contribution Strategy

In this screen cast we walk thought he process of forking the amazing StorEvil project by Dave Foley and submitting a contribution back via GitHub.

Contributing to Open Source Projects On GitHub For .NET Developers Part 2

Part 2: Publishing a Visual Studio Project to GitHub & Basic Git Workflow

In this screen cast we create a local git repository, define a .gitignore file and publish the WcfGoneWild project to GitHub. Many thanks to Jeff Schumacher, to pairing with me on the project and helping to cement my understanding of WCF.

Contributing to Open Source Projects On GitHub For .NET Developers Part 1

Part 1: Installation & GitHub Account Creation & Setup

In this screen cast we download and install git, create a public/private key pair, create our GitHub account and configure it to use our public key.

Next : Part 2, Part 3

Bonus: Using TeamCity to Maintain a Stack of OSS Tools

An Implementation of Castle Windsor Bootstrapper for Caliburn.Micro

This last week Jeff Schumacher and I have been working on a fairly complex set of business logic driving the entire design from the outside in with specification style unit tests. In an effort to help our tester get a head start validating the logic and assumptions in our code we promised to create a simple UI. Jeff has some WPF experience, so I suggested we do a simple WPF application and he can show me his “XAML Fu”. I have yet to get beyond playing with XAML, so having a little toy project and pairing with someone who has some experience already is a great way to get your feet wet. I also suggested we use Calibun.Micro and awesome little library Rob Eisenberg that brings convention over configuration for WPF applications to the table. So we pulled down the library and cracked open Rob’s Soup to Nuts series of tutorials.

In part two of his series, Rob describes how to override Caliburn.Micro’s default Bootstrapper with a custom implementation using the Managed Extensibility Framework. At work we use Castle Windsor, so we followed along with the tutorial injecting Castle magic at the appropriate spots.

To provide a custom bootstrapper for Caliburn.Micro, you simply inherit from the Bootstrapper<T> where T is your shell view model and then override the GetInstance, GetAllInstances and BuildUp methods providing your own implementation. With the exception of the BuildUp method, they pretty much line up perfectly with Castle Windsor’s interface allowing you to simply wrap it. The BuildUp method is used to perform property injection on an already created instance, Castle Windsor does property injection by default on resolution of your types and does not explicitly expose a build up method. This is easily overcome by adding an extension method to the container to provide that service.

public static class WindsorExtensions

        public static void BuildUp(this IWindsorContainer container, object instance)
                .Where(property =&gt; property.CanWrite &amp;&amp; property.PropertyType.IsPublic)
                .Where(property =&gt; container.Kernel.HasComponent(property.PropertyType))
                .ForEach(property =&gt; property.SetValue(instance, container.Resolve(property.PropertyType), null));

The bootstrapper then looks like this:

public class CastleBootstrapper : Bootstrapper
        private ApplicationContainer container;

        protected override void Configure()
            container = new ApplicationContainer();

        protected override object GetInstance(Type service, string key)
            if (string.IsNullOrWhiteSpace(key))
                return container.Resolve(service);

            return container.Resolve(key);

        protected override IEnumerable GetAllInstances(Type service)
            return (IEnumerable) container.ResolveAll(service);

        protected override void BuildUp(object instance)

The ApplicationContainer class is simply inherits from WindsorContainer, I like to seperate out my component registration from my bootstrapping code. It looks something like this:

public class ApplicationContainer : WindsorContainer
        public ApplicationContainer()



        private void RegisterViewModels()
                         .Where(x =&gt; x.Namespace.EndsWith("ViewModels"))
                         .Configure(x =&gt; x.LifeStyle.Is(LifestyleType.Singleton)));

This code is all that is needed to get the sample application from the tutorials to work with Castle Windsor.