If you do find or use such a license, it's definitely not open source. According to the OSI, the only authority on what constitutes open source, open source license must not discriminate against fields of endeavour:
6. No Discrimination Against Fields of Endeavor
The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.
According to RMS, adding usage restrictions to an open source lucense is not a very effective at stopping the software from being used for evil but is a huge headache for a FOSS ecosystem (because it adds to the number of subtly incompatible licenses that we need to work around)
And I'll clarify, in today's world code has severe moral repercussions, especially in the fields of AI and vision. Why shouldn't we have more discussions over ways that we can add caveats and nuances to the licenses in order to distance our consciences from repercussions.
We should, but this isn't the right way to have the discussion IMO. As OP noted, this is impossible to enforce, so it's more symbolic than anything. Which is fine, but it comes with the cost that anyone in a company that observes OSS licenses will need to decide whether it's worth having legal sign off on it, even if they aren't involved with a military (since it doesn't fit under a pre-approved license). This applies not only to OP's code, but any code that uses it as well, so even if OP decides this cost is worth it other non-military users may avoid the code anyway.
No, but projects insisting on OS won't use it, and every online discussion about it will derail into a discussion about calling things "Open Source" that don't fit the OSI criteria and the pro and cons of creating your own licenses ;)
Since OP explicitly mentioned "open sourcing" it I think it's a fair concern to point out.
The power to sue isn't the only form of authority worth considering. Many projects and groups consider OSI authoritative in what constitutes open source, including Debian, Ubuntu, Mozilla, the Apache foundation, the Creative Commons non-profit, RedHat, Google (at least when they hosted Google Code), and others. Personally, I'm glad that the OSI occupies this role, otherwise, the term "open source" would inevitably be diluted to mean gratis or even worse.
Comments
If you do find or use such a license, it's definitely not open source. According to the OSI, the only authority on what constitutes open source, open source license must not discriminate against fields of endeavour:
See the open source definition: https://opensource.org/osd
I would encourage you to use a normal open source license, like MIT, and to not worry about trying to control who uses the software for what.
Why should the open source philosophy trump any other moral objections?
According to RMS, adding usage restrictions to an open source lucense is not a very effective at stopping the software from being used for evil but is a huge headache for a FOSS ecosystem (because it adds to the number of subtly incompatible licenses that we need to work around)
https://www.gnu.org/philosophy/programs-must-not-limit-freed...
And I'll clarify, in today's world code has severe moral repercussions, especially in the fields of AI and vision. Why shouldn't we have more discussions over ways that we can add caveats and nuances to the licenses in order to distance our consciences from repercussions.
We should, but this isn't the right way to have the discussion IMO. As OP noted, this is impossible to enforce, so it's more symbolic than anything. Which is fine, but it comes with the cost that anyone in a company that observes OSS licenses will need to decide whether it's worth having legal sign off on it, even if they aren't involved with a military (since it doesn't fit under a pre-approved license). This applies not only to OP's code, but any code that uses it as well, so even if OP decides this cost is worth it other non-military users may avoid the code anyway.
Have all of the discussions about that you want, just don't pretend that what software you release is open source if it in reality is not.
On what basis is there any authority? Just discriminate against a FoE, and call it OS anyway - are they going to sue?
No, but projects insisting on OS won't use it, and every online discussion about it will derail into a discussion about calling things "Open Source" that don't fit the OSI criteria and the pro and cons of creating your own licenses ;)
Since OP explicitly mentioned "open sourcing" it I think it's a fair concern to point out.
True, but that only matters to the degree you care about that vs Military use.
The power to sue isn't the only form of authority worth considering. Many projects and groups consider OSI authoritative in what constitutes open source, including Debian, Ubuntu, Mozilla, the Apache foundation, the Creative Commons non-profit, RedHat, Google (at least when they hosted Google Code), and others. Personally, I'm glad that the OSI occupies this role, otherwise, the term "open source" would inevitably be diluted to mean gratis or even worse.