דֶרֶךְ בְּרִיָּתוֹ שֶׁל אָדָם לִהְיוֹת נִמְשָׁךְ בְּדֵעוֹתָיו וּבְמַעֲשָׂיו אַחַר רֵעָיו וַחֲבֵרָיו וְנוֹהֵג כְּמִנְהַג אַנְשֵׁי מְדִינָתוֹ. לְפִיכָךְ צָרִיךְ אָדָם לְהִתְחַבֵּר לַצַּדִּיקִים וִלֵישֵׁב אֵצֵל הַחֲכָמִים תָּמִיד כְּדֵי שֶׁיִּלְמַד מִמַּעֲשֵׂיהֶם. וִיִתִרַחֵק מִן הָרְשָׁעִים הַהוֹלְכִים בַּחשֶׁךְ כְּדֵי שֶׁלֹּא יִלְמֹד מִמַּעֲשֵׂיהֶם. הוּא שֶׁשְּׁלֹמֹה אוֹמֵר (משלי יג כ) "הוֹלֵךְ אֶת חֲכָמִים יֶחְכָּם וְרֹעֶה כְסִילִים יֵרוֹעַ". וְאוֹמֵר אַשְׁרֵי הָאִישׁ וְגוֹ'. וְכֵן אִם הָיָה בִּמְדִינָה שֶׁמִּנְהֲגוֹתֶיהָ רָעִים וְאֵין אֲנָשֶׁיהָ הוֹלְכִים בְּדֶרֶךְ יְשָׁרָה יֵלֵךְ לְמָקוֹם שֶׁאֲנָשֶׁיהָ צַדִּיקִים וְנוֹהֲגִים בְּדֶרֶךְ טוֹבִים. וְאִם הָיוּ כָּל הַמְּדִינוֹת שֶׁהוּא יוֹדְעָם וְשׁוֹמֵעַ שְׁמוּעָתָן נוֹהֲגִים בְּדֶרֶךְ לֹא טוֹבָה כְּמוֹ זְמַנֵּנוּ. אוֹ שֶׁאֵינוֹ יָכוֹל לָלֶכֶת לִמְדִינָה שֶׁמִּנְהֲגוֹתֶיהָ טוֹבִים מִפְּנֵי הַגְּיָסוֹת אוֹ מִפְּנֵי הַחֹלִי יֵשֵׁב לְבַדּוֹ יְחִידִי כָּעִנְיָן שֶׁנֶּאֱמַר (איכה ג כח) "יֵשֵׁב בָּדָד וְיִדֹּם". וְאִם הָיוּ רָעִים וְחַטָּאִים שֶׁאֵין מְנִיחִים אוֹתוֹ לֵישֵׁב בַּמְּדִינָה אֶלָּא אִם כֵּן נִתְעָרֵב עִמָּהֶן וְנוֹהֵג בְּמִנְהָגָם הָרַע יֵצֵא לַמְּעָרוֹת וְלַחֲוָחִים וְלַמִּדְבָּרוֹת. וְאַל יַנְהִיג עַצְמוֹ בְּדֶרֶךְ חַטָּאִים כָּעִנְיָן שֶׁנֶּאֱמַר (ירמיה ט א) "מִי יִתְּנֵנִי בַמִּדְבָּר מְלוֹן אֹרְחִים":
It is human nature to be attracted to the ideas and actions of one's neighbors and friends and to follow the customs of the people of his land. Therefore, a person needs to bind himself to the righteous and always dwell in the midst of the wise in order that he might learn from their deeds and keep far from the evil ones who walk in darkness so as not to learn from their deeds. This is what Shlomo says (Proverbs 13:20), "He who walks with the wise becomes wise and he who befriends fools will suffer." And it states, (Psalms 1:1), "Happy is the man [who has not followed the advice of the wicked)." And thus, if one lives in a land whose customs are evil and people do not follow a straight path, one should go to a land where the people are righteous and are accustomed to following a good path. And if all the lands that he knows and hears reports of are accustomed to follow a path that is not good, like our time, or he is not able to go to a land the customs of which are good, because of troops or health, he should remain alone by himself, as it says, "Sit alone and be silent" (Lamentations 3:28). If they are evil and sinful people and do not allow him to stay there in the land unless he mixes among them and follows their evil ways, he should go out to caves, thickets and deserts. And let him not accustom himself to the way of the sinners, as it says, "Who will give me in the wilderness, a lodging for guests" (Jeremiah 9:1).
