Bower Errors on Windows

I started playing with Bower and right out of the gate, there are a couple errors I encountered while using it on Windows. So I want to do a quick post on what I do to resolve the errors.

Let’s use installing twitter bootstrap as an example. I ran the following command:

bower install bootstrap

Right away I received the following error.

bower cloning git://
bower cached git://
bower fetching bootstrap
bower error status code of git: 127

Do some Googling a bit and it seems like the solution to the problem was put git in my PATH. That’s weird. It is in my PATH. Running “git –version” in command prompt clearly shows I have msysgit installed and running “where git” shows me it points to “C:\RailsInstaller\Git\cmd\git.cmd”. Okay, even though I didn’t literally install msysgit myself, it was installed as part of the RailsInstaller.

As a last resort, I’ll just take a quick peek into the bower source code at least to see where it throws that error. So I found package.js. How Bower works in my case is it will construct a git URL using some naming convention and uses git on my machine to run some commands using spawn from child_process. From my past memory, spawn actually was not able to run .bat and .cmd files, but it was able to run .exe files. So this may be the problem since my git points to git.cmd. I then updated my PATH variable to include the path to git.exe directly. Remember to add it after the RailsInstaller path since order matters.

Run “bower install bootstrap”. Error again.

bower cloning git://
bower cached git://
bower fetching bootstrap
bower error status code of git: 128

There where errors, here's a summary of them:
- status code of git: 128
fatal: Not a git repository (or any of the parent directories): .git

There is a status code 128 error. It’s a different error. At least it seems like a progress. Googling more and it may have something to do with the bower cache. I assume Bower works somewhat like npm. So let’s just open C:\Users\<Username>\AppData\Roaming and there I see both bower\cache and bower-cache. At this point, I know I’m very close and I don’t want to investigate further on which to delete. I’ll just delete both.

Run “bower install bootstrap” again. tada! Here is the message for success.

bower cloning git://
bower caching git://
bower fetching bootstrap
bower checking out bootstrap#v2.2.1
bower copying C:\Users\YourUsername\AppData\Roaming\bower\cache\bootstrap\c1ee45ee19795a66de4a0c45758fe0b1
bower cloning git://
bower caching git://
bower fetching jquery
bower checking out jquery#1.8.3
bower copying C:\Users\YourUsername\AppData\Roaming\bower\cache\jquery\cf68c4c4e7507c8d20fee7b5f26709d9
bower installing bootstrap#2.2.1
bower installing jquery#1.8.3

Since yeoman uses Bower internally, yeoman now also works and you can run “yeoman install bootstrap” to install twitter bootstrap for your yeoman project, given that you have yeoman set up for Windows of course.

Happy coding!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s