aec
aec

Reputation: 1135

How do I enable the Ruby 2.3 `--enable-frozen-string-literal` globally in Rails?

I am building a greenfield Rails application on top of Ruby 2.3, and I would like all Rails commands (e.g. rails s, rails c) and all Ruby commands (e.g. rake do:something) to use the new immutable-String functionality introduced in Ruby 2.3. (See, e.g. https://wyeworks.com/blog/2015/12/1/immutable-strings-in-ruby-2-dot-3/)

So, how do I pass that lovely --enable-frozen-string-literal Ruby option down to Ruby in all possible contexts where some command I issue bottoms out in Ruby?

Thanks in advance!

Upvotes: 16

Views: 5629

Answers (1)

Sa-ryong Kang
Sa-ryong Kang

Reputation: 296

As far as I know, best way to do it is setting environment variable like followings:

export RUBYOPT=--enable-frozen-string-literal

or

setenv RUBYOPT --enable-frozen-string-literal

However, don't try it right now. It simply doesn't work because some codes in Bundler gem are attempting to modify frozen String. Wait until they fix the problem.

Upvotes: 24

Related Questions