You found a library that does exactly what your feature needs. You add it in one line and the tests pass. Then a colleague asks a question nobody on the team can answer. What licence is it under, and are we allowed to use it like this?
Most developers never learn this, because most of the time nothing goes wrong. But an hour of learning now will make you the person who can answer that question.
Start with the basic idea. Code is protected by copyright as soon as someone writes it. A licence is the permission the author gives you to use it, and the conditions that come with that permission. So a repository with no licence at all is not free to use. It means nobody has given you permission.
Most licences fall into two families. Permissive licences, such as MIT, BSD and Apache 2.0, let you use the code almost any way you like, including in closed commercial products, as long as you keep the copyright and licence notices. Apache 2.0 also gives you an explicit patent licence from the contributors, which is one reason companies like it.
Copyleft licences, such as the GPL, ask for something back. If you distribute software that includes GPL code, you must make the source of the whole combined work available under the same licence. The important word is distribute. Running GPL software on your own servers is usually not distribution. The AGPL closes that gap, and also applies when users interact with the software over a network, which is why many companies are cautious about it. The LGPL sits in between and is mainly about libraries you link to.
Licences can also change between versions. Elasticsearch moved away from Apache 2.0 in 2021, HashiCorp moved Terraform to the Business Source License in 2023, and Redis changed its licence in 2024. The version you added last year may not be under the same terms as the next one.
Then look at your own project. Most package managers record each dependency's licence, often as a short SPDX identifier like MIT or Apache-2.0. Tools such as license-checker for npm or pip-licenses for Python will list them all.
And when the answer is unclear, ask your company's legal or open source team. That is what they are there for. Your job is to notice the question before the library ships.
– Asael Shinder
Top comments (0)