Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Fix #103. Add '-Ku' to list of args and prevent problems with utf-8 #127

Closed
wants to merge 1 commit into from

Conversation

zenbro
Copy link

@zenbro zenbro commented Jan 15, 2018

I noticed that vscode-ruby checks the code with these arguments: -Wc -Ku.
It turns out that adding -Ku to list of arguments solves problem with utf-8 on macOS (#103).

man ruby says

-K kcode  Specifies KANJI (Japanese) encoding. The default value for script encodings (__ENCODING__) and external encodings
          (Encoding.default_external) will be the specified one. kcode can be one of

                     e       EUC-JP

                     s       Windows-31J (CP932)

                     u       UTF-8

                     n       ASCII-8BIT (BINARY)

And nothing seems broken.

@Arcanemagus
Copy link
Member

The -K option was replaced with the -E options clear back in Ruby v1.8, and actually throws a warning in current versions of Ruby so that can't be used.

See #72 (comment) for the warning, and #78 for the original -E___ PR.

@zenbro
Copy link
Author

zenbro commented Jan 18, 2018

Thanks for the feedback. Good point, I close this PR.

@zenbro zenbro closed this Jan 18, 2018
@zenbro zenbro deleted the fix-problems-with-utf8 branch January 18, 2018 10:47
@Arcanemagus
Copy link
Member

I don't have a mac to test any of this on, my only guess is that the ruby getting called from within Atom is some positively ancient version that macOS is bundling and what you are getting in the terminal is a different version.

@zenbro
Copy link
Author

zenbro commented Jan 19, 2018

I tried to debug this case via

const output = await helpers.exec('ruby', ['--version'], {});
console.log(output);

and it's returned: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
but problems from #103 still exists.
Atom launched not from terminal btw.

Strange things 😐

@Arcanemagus
Copy link
Member

Hmmmmmmm, we already know that the command line arguments for the macOS version of Ruby are different from every other OS, maybe whoever is making macOS Ruby didn't get the memo on the --external-encoding/--internal-encoding changes and still only has -K implemented? 😮

This is what happens on Windows:
image

If you run that second command do you get the warning?

@zenbro
Copy link
Author

zenbro commented Jan 22, 2018

Yep.

> ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]

> which ruby
/usr/local/bin/ruby

> ruby -w -c --external-encoding=utf-8 --internal-encoding=utf-8 -Ku ./bad.rb
ruby: warning: -K is specified; it is for 1.8 compatibility and may cause odd behavior
./bad.rb:2: warning: assigned but unused variable - payload
./bad.rb:13: syntax error, unexpected keyword_end, expecting end-of-input
fruit.each end |e|

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants