"'jekyll: command not found' in post-receive hook"

I'm trying to set up my server so that I can edit blog posts locally and push them to a bare Git repository on my server, which will auto-publish the changes with Jekyll. I'm using a post-receive hook to do this.

I was getting a weird error that I was stuck on for a couple of hours. Ruby is installed on the server under RVM, and Jekyll is installed as a Gem. I added RVM to my PATH in .bashrc and the jekyll command worked fine from the command line. So I added a post-receive script that would do some magic and run Jekyll to generate the new site from the updated Git repository after it receives a push. But when I pushed from my local machine, I was getting the error jekyll: command not found from the post-receive script.

The solution was to add the -l flag to #!bin/bash at the top of the script. I found this out here.