Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passenger_preload_bundler does not work correctly with passenger_env_var RUBYOPT #2424

Closed
Tietew opened this issue May 23, 2022 · 4 comments
Closed
Milestone

Comments

@Tietew
Copy link

Tietew commented May 23, 2022

Issue report

Question 1: What is the problem?

passenger_preload_bundler on; does not work correctly with passenger_env_var RUBYOPT something.

  • What is the expected behavior?
    Our Rack application works normally.

  • What is the actual behavior?
    Passenger fails to start the Rack application with following error:

Error: The application encountered the following error: You have already activated strscan 3.0.1,
but your Gemfile requires strscan 3.0.3. Since strscan is a default gem,
you can either remove your dependency on it or try updating to a newer version of bundler
that supports strscan as a default gem. (Gem::LoadError)
  • How can we reproduce it?
  1. Create a simple Rack app

Gemfile

source 'https://rubygems.org'
gem 'rack'
gem 'strscan' # Ruby 3.1's default gem is 3.0.1, current latest is 3.0.3

config.ru

#!/usr/bin/env ruby
require 'bundler/setup'
Bundler.require
run lambda { |env| [200, {'Content-Type'=>'text/plain'}, ["strscan=#{StringScanner::Version}\n"]] }
  1. Install
$ bundle
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 2.3.13
Fetching rack 2.2.3
Fetching strscan 3.0.3
Installing strscan 3.0.3 with native extensions
Installing rack 2.2.3
Bundle complete! 2 Gemfile dependencies, 3 gems now installed.
Bundled gems are installed into `./vendor/bundle`
  1. Set up an Nginx config including passenger_env_var RUBYOPT.
server {
    listen 80;
    server_name myapp.example.com;
    root /var/www/test2/public;
    location / {
        passenger_enabled on;
        passenger_app_env production;
        passenger_app_root /var/www/test2;
        passenger_preload_bundler on;
        passenger_env_var RUBYOPT -W0; # just supress warnings
    }
}
  1. Access http://myapp.example.com

Question 2: Passenger version and integration mode:
Nginx 1.21.6
Passenger 6.0.14 (open source)

Question 3: OS or Linux distro, platform (including version):
Ubuntu 18.04 (bionic) x86_64

Question 4: Passenger installation method:
RubyGems, no Gemfile
(Passenger is installed globally with no Gemfile)

Question 5: Your app's programming language (including any version managers) and framework (including versions):
Ruby 3.1.2

Question 6: Are you using a PaaS and/or containerization? If so which one?
Amazon EC2

Question 7: Anything else about your setup that we should know?
Ruby is installed via rbenv globally.
nginx.conf includes following:

    passenger_root /usr/local/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/passenger-6.0.14;
    passenger_ruby /usr/local/rbenv/shims/ruby;

When Gemfile includes gem 'strscan'

passenger_preload_bundler off; passenger_preload_bundler on;
No passenger_env_var error (intended) strscan=3.0.3
passenger_env_var RUBYOPT error (intended) ERROR (this issue)

When Gemfile DOES NOT include gem 'strscan'

passenger_preload_bundler off; passenger_preload_bundler on;
No passenger_env_var strscan=3.0.1 strscan=3.0.1
passenger_env_var RUBYOPT strscan=3.0.1 strscan=3.0.1
@Tietew Tietew changed the title passenger_preload_bundler does not work correctly with YJIT passenger_preload_bundler does not work correctly with passenger_env_var RUBYOPT May 23, 2022
@Tietew
Copy link
Author

Tietew commented May 23, 2022

Update: YJIT is unrelated. Defining RUBYOPT will trigger this issue.

@Tietew
Copy link
Author

Tietew commented May 23, 2022

Workaround: Following settings works correctly:

passenger_env_var RUBYOPT "-W0 -rbundler/setup";

@CamJN
Copy link
Member

CamJN commented Jul 23, 2022

Working on this for next release.

@CamJN CamJN added this to the 6.0.15 milestone Jul 23, 2022
@Tietew
Copy link
Author

Tietew commented Sep 30, 2022

6.0.15 works fine. Thank you.

@Tietew Tietew closed this as completed Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants