【问题标题】:"control characters are not allowed at line 1 column 1 (Psych::SyntaxError)" during gem install or bundle install“在第 1 行第 1 列不允许使用控制字符(Psych::SyntaxError)”在 gem 安装或捆绑安装期间
【发布时间】:2015-04-13 15:12:32
【问题描述】:

在尝试使用 bundle install 安装 Rails gem 时,当捆绑程序尝试 gem install 某些 gem(如 Nokogiri)时,我一直收到错误消息“第 1 行第 1 列不允许使用控制字符”。

$ 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

这里有一些类似的问题:

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

(我认为我的问题不是重复的,因为在这种情况下,错误发生在使用 bundle install 时,而在上述情况下,它发生在使用 capistrano 部署时,但我承认这个问题非常相似。)

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'

【问题讨论】:

    标签: ruby-on-rails gem bundler


    【解决方案1】:

    我的解决方案是在 bundle install 之前执行此操作:

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

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

    将其添加到您的 ~/.bashrc~/.bash_profile 以防止将来出现此问题。

    免责声明:我没有调查过这些变量的作用,也不知道它们是否适用于所有人,比如非英语环境。

    【讨论】:

      猜你喜欢
      • 2015-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多