ROME — The Italian government learned the hard way, early this year, that no good deed goes unpunished.

Acting under a 2015 European Union directive addressing the global disaster caused by plastic bags, which take hundreds of years to degrade, Italian lawmakers enacted a measure banning the use of plastic bags for fruit, vegetables and baked goods in favor of eco-friendly biodegradable and compostable alternatives.

The government was firm on one point: The new bags could not be given out for free, and the charge of 1 euro cent to 3 euro cents per eco-friendly bag had to appear on the sales bill. Failure to charge consumers would result in a fine for the retailer.

But since the law went into effect on Jan. 1, it has been met with a flood of protests in grocery stores and supermarkets throughout Italy, as well as on social media.