(Imām Bukhārī narrates): Abu Ma'mar narrated to us, he said: Abdul Warith narrated to us from Abdul Aziz, he said that
a man asked Anas, may Allāh be pleased with him: What have you heard from the Prophet ﷺ regarding garlic? So he said: The Prophet ﷺ said: Whoever eats from this tree should not come near us, or he said: should not pray with us.
حَدَّثَنَا أَبُو مَعْمَرٍ، قَالَ حَدَّثَنَا عَبْدُ الْوَارِثِ، عَنْ عَبْدِ الْعَزِيزِ، قَالَ سَأَلَ رَجُلٌ أَنَسًا مَا سَمِعْتَ نَبِيَّ اللَّهِ صلى الله عليه وسلم فِي الثُّومِ فَقَالَ قَالَ النَّبِيُّ صلى الله عليه وسلم " مَنْ أَكَلَ مِنْ هَذِهِ الشَّجَرَةِ فَلاَ يَقْرَبْنَا، أَوْ لاَ يُصَلِّيَنَّ مَعَنَا ".
Reference: Sahih Al Bukhari 856