We derive the bar fraction in three different environments ranging from the field to Virgo and Coma clusters, covering an unprecedentedly large range of galaxy luminosities (or, equivalently, stellar masses). We confirm that the fraction of barred galaxies strongly depends on galaxy luminosity. We also show that the difference between the bar fraction distributions as a function of galaxy luminosity (and mass) in the field and Coma cluster are statistically significant, with Virgo being an intermediate case. We interpret this result as a variation of the effect of environment on bar formation depending on galaxy luminosity. We speculate that brighter disk galaxies are stable enough against interactions to keep their cold structure, thus, the interactions are able to trigger bar formation. For fainter galaxies the interactions become strong enough to heat up the disks inhibiting bar formation and even destroying the disks. Finally, we point out that the controversy regarding whether the bar fraction depends on environment could be resolved by taking into account the different luminosity ranges of the galaxy samples studied so far.