vscode-ruby version: 0.5.2Verified ruby, ruby-debug-ide and ruby-debug-basex19 installed
Should be able to run ruby scripts that use the gem 'xcodeproj' using VS Code
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'
A ruby script that use 'xcodeproj' gem:
#!/usr/bin/env ruby
require 'xcodeproj'
project = Xcodeproj::Project.open("/Users/ido/projects/sample/sample.xcodeproj")
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

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.
Most helpful comment
Set up your launch configuration like so:
And everything will be all good.