Vscode-ruby: Encoding issue when using gem 'xcodeproj'

Created on 7 Aug 2016  路  2Comments  路  Source: rubyide/vscode-ruby

Environment

  • vscode-ruby version: 0.5.2
  • Ruby version: 2.3.0p0 (revision 53290)
  • VS Code version: 1.4.0
  • Operating System: OS X El Captian (10.11.5)

Verified ruby, ruby-debug-ide and ruby-debug-basex19 installed

Expected behavior

Should be able to run ruby scripts that use the gem 'xcodeproj' using VS Code

Actual behavior

When executing the script from visual studio code using ruby extension I get the following error:

Uncaught exception: invalid byte sequence in US-ASCII
    /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:86:in `match'
    /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:86:in `match'
    /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:86:in `file_in_conflict?'
    /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:19:in `read_from_path'
    /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/project.rb:200:in `initialize_from_file'
    /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/project.rb:102:in `open'
    /Users/XXXXXX/script.rb:4:in `<top (required)>'
    /usr/local/bin/rdebug-ide:23:in `load'
    /usr/local/bin/rdebug-ide:23:in `<main>'
/usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:86:in `match': invalid byte sequence in US-ASCII (ArgumentError)
    from /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:86:in `match'
    from /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:86:in `file_in_conflict?'
    from /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/plist.rb:19:in `read_from_path'
    from /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/project.rb:200:in `initialize_from_file'
    from /usr/local/lib/ruby/gems/2.3.0/gems/xcodeproj-1.2.0/lib/xcodeproj/project.rb:102:in `open'
    from /Users/XXXXXXX/script.rb:4:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.3.0/gems/ruby-debug-ide-0.6.0/lib/ruby-debug-ide.rb:88:in `debug_load'
    from /usr/local/lib/ruby/gems/2.3.0/gems/ruby-debug-ide-0.6.0/lib/ruby-debug-ide.rb:88:in `debug_program'

Steps to reproduce the problem

A ruby script that use 'xcodeproj' gem:

#!/usr/bin/env ruby
require 'xcodeproj'
project = Xcodeproj::Project.open("/Users/ido/projects/sample/sample.xcodeproj")

Notes

I had a similar issue on a jenkins slave and managed to solve it by running the following commands before running the ruby script:

export LANG=en_US.UTF-8
export LC_COLLATE=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export LC_MESSAGES=en_US.UTF-8
export LC_MONETARY=en_US.UTF-8
export LC_NUMERIC=en_US.UTF-8
export LC_TIME=en_US.UTF-8
export LC_ALL=en_US.UTF-8

I didn't find any way to set the environment variable in VS Code before executing the ruby script

Most helpful comment

Set up your launch configuration like so:

{
      "name": "Debug Local File with env settings",
      "type": "Ruby",
      "request": "launch",
      "program": "${workspaceRoot}/script.rb",
      "env": {
            "LANG": "en_US.UTF-8",
            "LC_COLLATE": "en_US.UTF-8",
            "LC_CTYPE": "en_US.UTF-8",
            "LC_MESSAGES": "en_US.UTF-8",
            "LC_MONETARY": "en_US.UTF-8",
            "LC_NUMERIC": "en_US.UTF-8",
            "LC_TIME": "en_US.UTF-8",
            "LC_ALL": "en_US.UTF-8"
      }
}

And everything will be all good.

All 2 comments

nis99xcavesy2dcafzc1x2cabhdqrncaktu317ca19vufvcahj5csfcarmog8xcafdxw0ica04hryeca9fnob0cacg26u9cav76t5gcagav0v4ca0ugimacasztj1dcakvsacgcaak4uzzcang6eih

Set up your launch configuration like so:

{
      "name": "Debug Local File with env settings",
      "type": "Ruby",
      "request": "launch",
      "program": "${workspaceRoot}/script.rb",
      "env": {
            "LANG": "en_US.UTF-8",
            "LC_COLLATE": "en_US.UTF-8",
            "LC_CTYPE": "en_US.UTF-8",
            "LC_MESSAGES": "en_US.UTF-8",
            "LC_MONETARY": "en_US.UTF-8",
            "LC_NUMERIC": "en_US.UTF-8",
            "LC_TIME": "en_US.UTF-8",
            "LC_ALL": "en_US.UTF-8"
      }
}

And everything will be all good.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  4Comments

rebornix picture rebornix  路  3Comments

clxy picture clxy  路  3Comments

epk picture epk  路  5Comments

abraham picture abraham  路  4Comments