thoughtbot / cocaine

A small library for doing (command) lines.
https://robots.thoughtbot.com
Other
785 stars 55 forks source link

encode command to ascii-8bit when on jruby #72

Closed mmustala closed 9 years ago

mmustala commented 9 years ago

I found out that the command needs to be encoded with ascii-8bit when using jruby. Otherwise the multibyte characters are not correctly interpreted.

I do not know if this encoding should be done when using jruby on windows but the current implementation will do it anyway.

This relates to an issue in paperclip https://github.com/thoughtbot/paperclip/issues/1702

mmustala commented 9 years ago

Adding the file spec/support/files/Neliö seems to have broken the cocaine.gemspec file listing. When installing the gem Rubygems says

cocaine at /home/mika/.rvm/gems/jruby-1.7.16.1/bundler/gems/cocaine-a9a4f337f8fa did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  [""spec/support/files/Neli\303\266""] are not files
mmustala commented 9 years ago

The last commit fixed the gemspec issue.

enebo commented 9 years ago

@mmustala Can you provide a reduced example of JRuby having the wrong encoding with backticks? If so, then please open an issue in jruby/jruby for this. We would like to squash this bug so you don't need to do workarounds like this.

mmustala commented 9 years ago

I created https://github.com/jruby/jruby/issues/2258 with pretty simple example how to reproduce the issue.

jyurek commented 9 years ago

So is it safe to say that since this was fixed in JRuby that there's nothing I can do to fix the problem?

enebo commented 9 years ago

This will be fixed for 1.7.17 which will probably be out on Monday. So it is only worth having a workaround if you care about pre-JRuby 1.7.17. Personally, I prefer encouraging/forcing the upgrade and not having libraries have version hacks; but I guess it is up to how many people complain to your project about it on an old version of JRuby.

jyurek commented 9 years ago

OK, we'll see how many people complain. If it's not too bad, I'll just recommend they upgrade JRuby. Thanks @mmustala and @enebo!