phusion / passenger_apt_automation

Tools for automatically building a Debian APT repository for Phusion Passenger
MIT License
20 stars 20 forks source link

passenger_system_ruby should support more Ruby versions than the ones provided by default by the distribution #11

Closed FooBarWidget closed 9 years ago

FooBarWidget commented 9 years ago

passenger_system_ruby currently only looks for Ruby versions provided by default by the distribution. For example, on Debian 6, it only looks for /usr/bin/ruby1.8 and /usr/bin/ruby1.9.1. But the user may actually have installed a newer Ruby version, e.g. through the Brightbox repository. We should support this.

phallstrom commented 9 years ago

Is there a reason this shouldn't fallback to whatever is returned via which ruby if it can't find one of the system ones? Having ruby installed in /usr/local/bin/ruby and this still fails.

FooBarWidget commented 9 years ago

I suppose we could use the ruby in PATH as final fallback. But how would you end up in a situation like that anyway? Our Passenger packages depend on a Ruby interpreter, so there should be a Ruby interpreter in /usr/bin. Did you perhaps make your own Ruby package that installs to /usr/local?

phallstrom commented 9 years ago

@FooBarWidget I may have done exactly that :-) And didn't bother to create the symlinks from /usr/bin, but did set it so that the package said it provided ruby. I suppose I am a weird little edge case, but seems like it might be a reasonable fall back in any case.

FooBarWidget commented 9 years ago

I'm not sure about this. All the other Debian packages assume that /usr/bin/rubyXX is available, so we do too. I think you should setup a symlink.

phallstrom commented 9 years ago

Probably. I'm not sure they assume that /usr/bin/rubyXX is available. They assume that calling ruby will work as the package has been installed. I've tricked several other packages this way. But I agree, I need to modify my package to setup the symlinks.

Still, worth considering... :)

antoineco commented 8 years ago

@FooBarWidget: I'm running into this issue while using Passenger together with the official Docker ruby image.

Example Dockerfile to reproduce:

FROM ruby:2.3.0

ENV PASSENGER_VERSION=5.0.27

# APT config
RUN apt update \ 
  && DEBIAN_FRONTEND=noninteractive apt install -y apt-transport-https \
  && echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger jessie main" > /etc/apt/sources.list.d/passenger.list \
  # Phusion Passenger PGP public key
  && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7 \
  && rm -rf /var/lib/apt/lists/* /tmp/*

# fake Ruby for passenger - avoids having multiple Ruby versions installed
# Ruby is built from source but 'passenger' package depends on:
# * ruby2.5 | ruby2.4 | ruby2.3 | ruby2.2 | ruby2.1 | ruby2.0 | ruby1.9.1 | ruby1.8 | ruby-interpreter
# * rubygems-integration (>= 1.8) | rubygems1.9.1 | rubygems1.9 | rubygems (>= 1.2)
# * ruby-rack
RUN apt update \ 
  && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends equivs \
  && echo "Package: ruby\nProvides: ruby-rack, ruby-interpreter" > /tmp/dummy-ruby \
  && echo "Package: rubygems-integration\nVersion: 2.5" > /tmp/dummy-rubygems \
  && cd /tmp \
  && equivs-build dummy-ruby \
  && equivs-build dummy-rubygems \
  && dpkg -i ruby*.deb \
  && DEBIAN_FRONTEND=noninteractive apt purge -y --auto-remove equivs \
  && rm -rf /var/lib/apt/lists/* /tmp/*

# symlink Ruby libdir
RUN ln -s /usr/local/lib/ruby /usr/lib/

# install passenger
RUN apt update \
  && DEBIAN_FRONTEND=noninteractive apt install -y \
       nginx-common=*-[0-9].${PASSENGER_VERSION}~jessie1 \
       nginx-extras=*-[0-9].${PASSENGER_VERSION}~jessie1 \
       passenger=*${PASSENGER_VERSION}-[0-9]~jessie1
❯❯❯ docker build -t foo .
[...]
Successfully built 1d4a3d2954a2

❯❯❯ docker run -it foo passenger_free_ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

❯❯❯ docker run -it foo which ruby
/usr/local/bin/ruby 

❯❯❯ docker run -it foo passenger-status
passenger_system_ruby: cannot find suitable Ruby interpreter