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

Gem json 2.9.1 breaks passenger-status command #2587

Open
23tux opened this issue Jan 10, 2025 · 2 comments · May be fixed by phusion/passenger_apt_automation#48
Open

Gem json 2.9.1 breaks passenger-status command #2587

23tux opened this issue Jan 10, 2025 · 2 comments · May be fixed by phusion/passenger_apt_automation#48
Assignees

Comments

@23tux
Copy link

23tux commented Jan 10, 2025

Issue report

Question 1: What is the problem?

  • What is the expected behavior?
    • passenger-status should not crash
  • What is the actual behavior?
    • passenger-status exits with this error
Traceback (most recent call last):
        11: from /usr/sbin/passenger-status:43:in `<main>'
        10: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         9: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         8: from /usr/local/bundle/gems/json-2.9.1/lib/json.rb:584:in `<top (required)>'
         7: from /usr/local/bundle/gems/json-2.9.1/lib/json.rb:586:in `<module:JSON>'
         6: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         5: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         4: from /usr/local/bundle/gems/json-2.9.1/lib/json/ext.rb:5:in `<top (required)>'
         3: from /usr/local/bundle/gems/json-2.9.1/lib/json/ext.rb:8:in `<module:JSON>'
         2: from /usr/local/bundle/gems/json-2.9.1/lib/json/ext.rb:15:in `<module:Ext>'
         1: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require': incompatible library version - /usr/local/bundle/gems/json-2.9.1/lib/json/ext/parser.so (LoadError)
# DebugDockerfile
FROM ruby:3.3.3-bullseye
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates \
    && apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7 \
    && echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bullseye main >> /etc/apt/sources.list.d/passenger.list \
    && apt-get update \
    && apt-get install -y \
      libnginx-mod-http-passenger \
    && rm -rf /var/lib/apt/lists/*

Building the image and running it with bash like this:

docker build -t debug_image -f DebugDockerfile .
docker run -it --rm --name debug_container debug_image  bash

Now calling the following commands:

> passenger-status # works as expected
> gem install json -v 2.9.1
> passenger-status # broken
Traceback (most recent call last):
        11: from /usr/sbin/passenger-status:43:in `<main>'
        10: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         9: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         8: from /usr/local/bundle/gems/json-2.9.1/lib/json.rb:584:in `<top (required)>'
         7: from /usr/local/bundle/gems/json-2.9.1/lib/json.rb:586:in `<module:JSON>'
         6: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         5: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
         4: from /usr/local/bundle/gems/json-2.9.1/lib/json/ext.rb:5:in `<top (required)>'
         3: from /usr/local/bundle/gems/json-2.9.1/lib/json/ext.rb:8:in `<module:JSON>'
         2: from /usr/local/bundle/gems/json-2.9.1/lib/json/ext.rb:15:in `<module:Ext>'
         1: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require': incompatible library version - /usr/local/bundle/gems/json-2.9.1/lib/json/ext/parser.so (LoadError)

Question 2: Passenger version and integration mode:

root@a934d2ae5a7f:/# passenger --version
Phusion Passenger(R) 6.0.24

Question 3: OS or Linux distro, platform (including version):

Debian 11.10 Bullseye

Question 4: Passenger installation method:

Your answer:
[ ] RubyGems + Gemfile
[ ] RubyGems, no Gemfile
[ ] Phusion APT repo
[ ] Phusion YUM repo
[ ] OS X Homebrew
[ ] source tarball
[x] Other, please specify:

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

  • Ruby 3.3.3

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

  • For example: Heroku, Amazon Container Services, Docker 1.9 with an image based on passenger-docker
Docker version 27.3.1, build ce12230
@CamJN
Copy link
Member

CamJN commented Jan 13, 2025

@FooBarWidget because any pure ruby implementation of the json gem is suuuuper slow, and because we have paying customers that run passenger-status a lot to track metrics, we probably have to fix the loading of gems rather than continue to do one-off removals or reimplementations.

@FooBarWidget
Copy link
Member

FooBarWidget commented Jan 15, 2025

@CamJN I've written a few refreshers that elaborate on how we handle gem dependencies:

In CLI tools such as passenger-status, we are allowed to depend on gems, and we are certainly allowed to depend on standard library gems.

The problem in this issue is different. passenger-status breaks because:

  1. passenger-status has shebang #!/usr/bin/passenger_system_ruby
  2. passenger_system_ruby is a small wrapper that runs "/usr/bin/ruby(OPTIONAL VERSION HERE)" (as opposed to the Ruby in $PATH). This wrapper only applies to Debian packages.
  3. When installing the Passenger Debian package inside the ruby Docker image, you end up with two Ruby versions:
    1. The one that's supplied with the image: /usr/local/bin/ruby which is version 3.3.3.
    2. The one that the Passenger Debian package depends on: /usr/bin/ruby which is version 2.7.4.
  4. The Docker image also sets the environment variable GEM_HOME=/usr/local/bundle. gem install json runs under Ruby 3.3 and installs to that directory. So when you run passenger-status (and thus /usr/bin/ruby), Ruby 2.7 ends up trying to activate the JSON gem that's compiled for Ruby 3.3.

The best solution is to modify passenger_system_ruby to unset the various Ruby environment variables that would make it behave differently: GEM_HOME, GEM_PATH, RUBYOPT.

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

Successfully merging a pull request may close this issue.

3 participants