Ruby gems have LICENSE file with the license text in each gem. Cocoa[Touch] open source frameworks (say ShareKit, StackKit, etc.) have license at the very beginning of each file (.h and .m). I am not sure about .NET or other interpreted languages (except ruby), but I'm pretty sure there are own choices at hand. I am wondering what are the reasons behind placing license into open source software source packages like this. Why not LICENSE file everywhere or at the beginning of every source file?

3 Answers 3


The choices seem very different, but aren't actually. The common practice is to put a notice (boilerplate) stating the license and its short form at the beginning of every source file to (a) make the licensing terms clear explicitely and (b) make sure the license isn't left out accidentally in copying. The license notification you find at the start of a file is usually not the full license, because the full GNU license covers many pages and would bloat source files quite a lot.

The full license is included in the LICENSE file to fulfill GPL's requirement that the license is distributed with the project. It suffices to have one file per project here. The LICENSE file also fills the role of a fall-back license: If you omit the boilerplate at the start of some file, the code is still covered by the project-wide license.

  • It's not only about GPL. BSD has 3 licenses which seem pretty short.
    – Eimantas
    Sep 28, 2011 at 14:27
  • Fair enough, for BSD licenses the LICENSE is not only in there for the size. Edited accordingly.
    – thiton
    Sep 28, 2011 at 14:30
  • Thanks for the update! So is it save just to have LICENSE file in project to cover all the files?
    – Eimantas
    Sep 28, 2011 at 16:13
  • Safe depends on your definition of save. Better to have the license in all files (e.g. for someone accessing your project via a google hit into your source control), but it /should/ be legally safe to have it only in the LICENSE. I ain't a lawyer, though.
    – thiton
    Sep 28, 2011 at 16:17

Copyright law is extremely complicated. Having software on the Internet developed and used by people worldwide makes it even worse as you have to comply to all copyright laws world-wide. You may not have to put the license in the headers and/or a LICENSE file. In some legislations this might even be irrelevant but the clearer you make it the more likely it becomes that it will be respected (from a legal way respected, not by every user ;-) ).

Aside from that: Software often doesn't contain only self-written code but bundle third party libraries. Having the header in the file makes it clear when you are using foreign copyright as well as when your code is being used by others.


Each source file contains a license extract to make sure that all the code within said file is in that license. The LICENSE file should contain the full text of the license for the whole project. Those two could be similar and they could not be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.