I can't add much background of what is known about the hymn, ידיד נפש אב הרחמן (or its official title: בקשה על הייחוד וחשק האהבה), to this excellent summary by Dr. Benny Gesundheit (and in Ham'aayan 45).
What is still unclear is, who wrote it? The common knowledge attributes it to R. Elazar Azkari (1533-1600) who first published it in his Sefer Haharedim (composed 1588, ep Venice, 1597 fol. 43a, that's page 45 on the thumbnail).
In his autograph notebook ( NY JTSA ms 3541), Azkari included drafts of much of the material that was to appear in Haredim, including the hymn. One can also find other original liturgy here, such as one of the few Kinot on the expulsion from Spain (fol. 3a- Benayahu, Sinai 88 (1981), pp. 40-47), but no mention is given to the name of the author, nor does Azkari claim to have penned it himself.
On the page in which Yedid Nefesh appears, in both the notebook (5b) and the print (43a) there is another Baqasha: "בקשה על הדבקות: אדון הכל הדרש לעם דורשיך..." followed by "רהטא: אורך מהוה ערב שמחת לבי" , the two combined poems bear the acrostic אלעזר אזכרי. This is definitely not the acrostic of Yedid Nefesh, yet this is probably the source of the conclusion that Azkari is also the author of the hymn. Who originated this assumption is also unclear. The earliest I could come up with was A.Z. Idelson Otzar Neginot vol. IV p. 119 which is 1923. The common knowledge was unknown to Nina Davis who published an English translation in 1897 (JQR OS IX, p. 290), who espoused a common knowledge of her own: "Attributed by some to Judah Halevi and by others to Israel Najara". Nonetheless, the common assumption leads to the common conclusion- that the true version is the one found in Haredim and the abovementioned autograph. (Roth, Shomer Emunim, 1959 II p. 410; Bet Aharon VYisrael 42 (Av 1992) p. 111; N.D. Shapira, Torah Sheb'al Peh, 2000, p. 114; more recently in piyut.org., including a link to the manuscript) where verse 2 ends שפחת עולם and verse 3 reads אנא אלי מחמד לבי.
I should add that a manuscript copy with the version similar to the one in the autograph is found in Dr. Steve Weiss's manuscript collection, as part of a Brit Milah ceremony copied in Italy in 18-19nth cent. In this copy, the end of verse 2 reads : שפחת עולם, but in verse 3: אנא אלי חמדת לבי. So too in ms BL Or. 10130 (Gaster 318) of similar provenance.
Ms 320 of the Guenzburg collection , a polyglot of at least 24 different items written in different stages. The earliest is at least the date of the censor 1611, the latest is the date of the second owner 1821. All the handwritings are Italian cursive. The last item is a series of poems, the last of which is Yedid Nefesh (photo here) under the following headline:
ד' בתים של שם בן ד' ב"ה ששמענו מפי קדוש מכבוד החכם השלם מהר"ר גדליה בן לגאון המושלם המקובל [הא]לקי כמהר"ר משה קורדוברו זצק"ל".
This doesn't necessarily qualify that Gedalia Cordovero, son of ReMaK, is the author. To be precise, it attributes to him the oral transmission. Having been transmitted orally for some time, might explain some of the variants. In any case Gedalia Cordevero and Elazar Azkari are likely to have been well acquainted.
Similar to the autograph notebook, and Haredim, here too the version at the end of verse 2: שפחת עולם, and in verse 3: יהמו רחמיך, וחוס נא, נכסוף נכסף, אנא אלי מחמד לבי חוסה נא אל תתעלם. (the only variant from notebook/ Haredim: חושה נא ואל תתעלם) But if the original source of the hymn is not neccesarily Azkari in Haredim, there is more creedence to be given to optional versions.
British Library Or. 10578 L/5 (Gaster 1352) is written in a Sephardic hand that could possibly date from the time of the author, and may have derived from the Cairo Genizah. It's a single folio written on one side only, just Yedid Nefesh alone. Here we clearly read at the end of verse 2: שמחת עולם, and verse 3: אנא אלי חמדת לבי.
Note: Although the geographic listing of the Guenzburg manuscript should read: Moscow - Russian State Library, Ms. Guenzburg 320, this collection is rightfully ours. I can only request that other scholars follow this example, if not for legal value, at least for moral value (see Mishnah, Ketuvot XIII 6).
Gmb 022
Comments:
Bency Eichorn: Benayahu mentioned this line from ms. Guenzburg 320, in Yosef Behiri, 1991, p. 544.
Ezra: Thanks Bency. Benyahu there asserts that this witness must have heard the poem from Gedalia Cordevero after his descent to Italy in 1583. This would be a full five years before Haredim was written (and 17 years before published). Conclusion: in addition to the notebook (undated), ms. Guenzburg 320 is an independent primary source of Ydid Nefesh.