Starting with a conjunction, this difficult verse speaks about ἡ γραφὴ, evidently referring to a particular scripture--part of the holy writings. While scholars customarily apply ἡ γραφὴ to a scriptural passage, no one seems certain which text James is referencing; nevertheless, sacred writing is evidently the focus of his language. See John 7:38.
Another question is how the spirit, which has taken up residence in Christians, yearns with envy. Or is God the one who envies ("jealously desires") the divine spirit that he has made to dwell in us?
"Or do you suppose it is to no purpose that the Scripture says, 'He yearns jealously over the spirit that he has made to dwell in us?'" (ESV)
Coffman's Commentary contains an interesting note about James 4:5-6:
Or think ye that the Scripture speaketh in vain? Doth the spirit which he made to dwell in us long unto envying?
It is the conviction here that spirit should be read Spirit, since the only spirit ever made to dwell in Christian hearts is the Holy Spirit.
This is a disputed text, of course, with almost as many renditions of it as there are translators and commentators, the first sentence usually being presented as a formula for introducing a Scriptural quotation. We agree with Lenski who said, "We are not convinced that the question is a formula of quotation; if it were, we should certainly expect the addition of saying that." The proof that this does not introduce a quotation from the Bible is that no quotation is given, a problem which has perplexed the commentators extensively. Rather than being troubled by the presentation of different views on it, we shall be content with giving what would appear to be the best rendition of it, as follows:
Or do you suppose that the Scripture speaks falsely? Does the Spirit that dwells in us strongly incline to envy?
This rendition, which actually is not out of harmony with our text above, also fits in beautifully with James 4:6, given by the same translation thus:
Indeed, it bestows superior favor; therefore, it is said, "God sets himself in opposition to the haughty, but gives favor to the lowly.
Note 15 in Coffman for James 4:5ff supplies this additional data:
Emphatic Diaglott (Brooklyn: Watch Tower Bible and Tract Society), p. 769.
That is the translation he quotes above. See https://www.studylight.org/commentary/james/4-5.html