I recently needed to automate launching VSCode from a rake task on my Macbook.. This post shows the steps necessary to allow this to work.