1

I've installed Ruby 2.2.2 (x64) via the Windows installer.

Then from the GitHub for Windows Git Bash Shell, installed Bundler via gem install bundler.

In my site repository I've created a file called Gemfile with the line gem 'github-pages'.

However when I try to run the bundler command, I receive

[!] There was an error parsing 'Gemfile': Undefined local variable or method '??g' for Gemfile. Bundler cannot continue.

 #    from C:/Users/User/Documents/GitHub/repository/Gemfile:1
 #    -------------------------------------------
 #     >   ??g e m    ' g i t h u b p a g e s '  #   ??g e m    ' g i t h u b p a g e s '
 #    -------------------------------------------

This also occurs from the Git Shell that runs Windows PowerShell.

It appears the first character is not parsing correctly and the file is parsing twice with the error, but unsure as to why.

1 Answer 1

1

I suspect this is a byte-encoding issue. Your text editor probably saved the file in UTF-16 format (2 bytes per character) with a 2-byte BOM (Byte order mark). That's showing up as the two question marks because Bundler apparently doesn't (at least by default) handle the BOM.

The spaces between the characters in the error messages are another clue that it's probably using UTF-16.

I suspect Bundler requires the file to be UTF-8-encoded (8 bits per character), and without a BOM.

To fix this, see if your code editor can be configured to save files in UTF-8.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @brian-morearty, spot-on. It must have been Notepad which saves in: ANSI - works (no BOM); Unicode - error @ '??gem'; Unicode big endian - error @ '??g' - voila! and UTF-8 - works (BOM ef bb bf). Then likely used Sublime with Preferences - Settings - Default as "default_encoding": "UTF-8".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.