Largo / ocran

Turn ruby files into .exe files on windows (supported safe fork of ocran)
MIT License
57 stars 5 forks source link

Handling Paths Given to -r and -I in RUBYOPT #20

Open shinokaro opened 4 months ago

shinokaro commented 4 months ago

RUBYOPT or the --rubyopt option in OCRAN is the only way to provide Ruby startup options for executables generated by OCRAN. In the future, supporting the -r and -I options in RUBYOPT will be necessary.

In the past, OCRAN (OCRA) did nothing with the paths in RUBYOPT.

Since Ruby 3.2, Bundler sets absolute paths in RUBYOPT in a bundle exec environment. The current OCRAN detects and removes these absolute paths added by Bundler.(https://github.com/Largo/ocran/commit/1369ee587f1430ad56823d3141953e9ab6d2f3b6)

We could replace the absolute paths in RUBYOPT with the absolute paths in the user's execution environment. However, in the user's execution environment, the paths may contain spaces, causing Ruby execution to fail.

Specifically, Ruby cannot correctly interpret quoted strings with -r or -I options in RUBYOPT. This is a Ruby issue. However, even if Ruby fixes this problem, we still need to support older versions of Ruby. We need a solution now.

Our options are:

  1. Modify the stub to allow specifying Ruby startup options (-r, -I).
  2. Modify the stub to launch Ruby and the application through a startup script built by OCRAN.

Implementing the first option requires changing the stub's source code.

The second option is already implemented in the InnoSetup builder. If complex preprocessing is required when launching the application, we can imagine a case where the application script set in OCRAN includes a "Ruby script to launch Ruby." (If we don't solve the problem now, someone will do it in the future.) If the second option works well, in the future, the significance of OCRAN providing a startup script builder will be defined as a service rather than a feature.

Note: I consider this a new feature. This functionality did not exist in OCRA.