Reputation: 1081
I'm trying to run our application under ruby 2.3 using the new ruby feature for automatic frozen strings turned on globally. (Ruby 2.3) This is normally done by passing the argument to a ruby script when starting as follows:
ruby --enable-frozen-string-literal ruby_code_file.rb
Unfortunately, our application is started using rackup, and I've tried the following command:
rackup --enable-frozen-string-literal
But this does not appear to work. How do I pass that parameter into Rack?
Upvotes: 4
Views: 1550
Reputation: 106067
You can't pass parameters for ruby
to rackup
, unfortunately. However, rackup
is really, really simple:
#!/usr/bin/env ruby
require "rack"
Rack::Server.start
The simplest solution, then, is to duplicate this file in your project (in, say, bin/frozen_rackup
) but change the first line to this:
#!/usr/bin/env ruby --enable-frozen-string-literal
Then make sure the file is executable (chmod u+x bin/frozen_rackup
) and run bin/frozen_rackup
instead of rackup
.
P.S. I'm guessing that --enable-frozen-string-literal
doesn't apply to gems your script requires, since it would break a lot of gems, but I haven't tested this and YMMV.
Upvotes: 6