An error was raised by libgit2. Folder name longer than 256 chars

114 Views Asked by At

I am using the yeoman nuget package in a visual studio .NET MVC project to generate an angularJS front end. After installing yeoman and generating an app, I get this error trying to commit to git:

An error occurred. Detailed message: An error was raised by libgit2. Category = Invalid (Error). Failed to open directory 'C:/my/project/node_modules/super/long/directory'

This is happening because of the dreaded Windows 256 character limit on file/directory names. How do I fix this so I can commit to git?

1

There are 1 best solutions below

0
On

I don't love this answer, but it works. The long paths were for 2 specific grunt node modules that I did not need. Specifically grunt-contrib-imagemin and grunt-google-cdn. So here's what I did:

  1. Move those folders out of the node_modules folder to some folder outside of your project.
  2. Now you will be able to commit to git, but your grunt build will fail.
  3. Remove cdnify and imagemin from the Gruntfile.js to remove those tasks from the build.