0
votes

When I added puma to Gemfile, I now get this error every time I run rails generator or rails server:

SyntaxError: /Users/admin/.rvm/gems/jruby-1.7.19@benchmark_jruby_puma/gems/puma-3.1.0-java/lib/puma/const.rb:103: invalid multibyte char (US-ASCII)

Without puma everything works fine. How to fix this issue?

1

1 Answers

0
votes

That line contains a non-ASCII character, but the file doesn’t include an encoding header. The default for JRuby 1.7 is to treat the source as ASCII encoded, so the result is the error you see. Later Ruby versions default to UTF-8.

1.7 still supports the old -K command line option though, so you can use this to set the source encoding. You will need the u option (i.e. -Ku). You will probably need to use the RUBYOPT environment variable to use it with Rails.

You can specify the environment variable separately for each command by starting the line with it, e.g.:

$ RUBYOPT=-Ku rails server

Or you can export it so you don’t need to keep retyping it:

$ export RUBYOPT=-Ku
$ rails server