1

When attempting to install Rails gems with bundle install I kept getting an error "control characters are not allowed at line 1 column 1" when bundler tried to gem install some gems, like Nokogiri.

$ gem install nokogiri -v 1.6.6.2
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
ERROR:  Error installing nokogiri:
    invalid gem: package is corrupt, exception while verifying: (<unknown>): control characters are not allowed at line 1 column 1 (Psych::SyntaxError) in /var/www/.rvm/gems/ext-rbx-2.5.2@rails2/cache/nokogiri-1.6.6.2.gem

Here are some similar questions:

cap deploy:migrations: Error: control characters are not allowed at line 1 column 1 (Psych::SyntaxError)

(I think my question is not a duplicate because in this case the error occurred when using bundle install, while in the case above it happened when deploying with capistrano, but I admit this question is very similar.)

Why am I getting a Psych error when trying to deploy with capistrano?

psych.rb error when deploying with Capistrano 'mapping not allowed in this context'

Community
  • 1
  • 1
David Winiecki
  • 4,093
  • 2
  • 37
  • 39

1 Answers1

0

The solution in my case was to execute this before bundle install:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

From sergiocampama: https://github.com/mperham/sidekiq/issues/929#issuecomment-17964326

Add that to your ~/.bashrc or ~/.bash_profile to prevent this problem in the future.

Disclaimer: I haven't investigated what these variables do and I don't know if they are correct for everyone, like non-English environments.

David Winiecki
  • 4,093
  • 2
  • 37
  • 39