You should be able to post in code just fine. Just place 3 backticks (the key on the left above the tab key) above and below your code on it’s own line and it will format as code.
If your terminal cannot locate a Gemfile I can only assume you are in the wrong directory. If you type
ls when in the terminal it should output a list of files and folders in the directory you are in. See if there is a Gemfile there.