After couple of hours, I finally overcame the issue.
In my opinion that problem occurs when we have different path and different versions of ruby.
I wasn't using mac's own ruby. (You can check it by writing "which ruby" to your console, the result should be "/usr/bin/ruby" if you haven't defined any other path.)
Hence I removed all of the ruby versions from my rvm.
After that, I also deleted the below line from my .bash_profile file.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
I hope it will help you as well.