phusion / passenger

A fast and robust web server and application server for Ruby, Python and Node.js
https://www.phusionpassenger.com/
MIT License
5.01k stars 548 forks source link

Support binaries install to wrong location #2401

Open bbaptist opened 2 years ago

bbaptist commented 2 years ago

Question 1: What is the problem?

Your answer:

What is the actual behavior? It ignores the HOME environment variable and takes what is in /etc/passwd for the home directory instead. This results in not being able to find the support binaries.

env | grep HOME
HOME=/app
/cnb/lifecycle/launcher "HOME=/app passenger-config install-agent -f"
Downloading a Phusion Passenger(R) agent binary for your platform

Copying agent-x86_64-linux.tar.gz from /layers/heroku_ruby/gems/vendor/bundle/ruby/2.6.0/gems/passenger-6.0.12/download_cache...
Download OK!
Extracting precompiled agent binary to /home/heroku/.passenger/support-binaries/6.0.12...
Checking whether the downloaded binary is usable...
The downloaded binary is usable.
Agent binary successfully downloaded and installed.
grep heroku /etc/passwd
heroku:x:1000:1000::/home/heroku:/bin/bash
/cnb/lifecycle/launcher passenger start -p 5000
Could not start the Nginx engine:
nginx: [alert] Unable to start Phusion Passenger(R): Support binary PassengerAgent not found (tried: /layers/heroku_ruby/gems/vendor/bundle/ruby/2.6.0/gems/passenger-6.0.12/buildout/support-binaries/PassengerAgent and /app/.passenger/support-binaries/6.0.12/PassengerAgent). There may be different causes for this:

 - Your 'passenger_root' setting is set to the wrong value. Please see https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_root to learn how to fix the value.
 - The PassengerAgent binary is not compiled. Please run this command to compile it: /layers/heroku_ruby/gems/vendor/bundle/ruby/2.6.0/gems/passenger-6.0.12/bin/passenger-config compile-agent
 - Your Passenger installation is broken or incomplete. Please reinstall Passenger. (-1: Unknown error)

Question 2: Passenger version and integration mode:

Your answer:

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

Your answer:

Question 4: Passenger installation method:

Your answer:

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

Your answer:

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

Your answer:

bbaptist commented 2 years ago

Easy reproduction of the issue for:

Install Docker and Cloud Native Buildpacks Pack tool.

Any passenger rails app will work but you can use a demo we made:

git clone https://github.com/satorix/satorix-rails-demo.git
cd satorix-rails-demo
pack build satorix-rails-demo --builder heroku/buildpacks:18
docker run --rm -p 8080:8080 --env PORT=8080 satorix-rails-demo

This will result in:

 --> Downloading a Phusion Passenger(R) agent binary for your platform

 --> Installing Nginx 1.20.1 engine

--------------------------

 [passenger_native_support.so] trying to compile for the current user (heroku) and Ruby interpreter...
     (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)
     Compilation successful. The logs are here:
     /tmp/passenger_native_support-156cpuy.log
 [passenger_native_support.so] successfully loaded.
2021/12/13 22:54:17 [alert] 68#0: Unable to start Phusion Passenger(R): Support binary PassengerAgent not found (tried: /layers/heroku_ruby/gems/vendor/bundle/ruby/2.6.0/gems/passenger-6.0.12/buildout/support-binaries/PassengerAgent and /app/.passenger/support-binaries/6.0.12/PassengerAgent). There may be different causes for this:

 - Your 'passenger_root' setting is set to the wrong value. Please see https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_root to learn how to fix the value.
 - The PassengerAgent binary is not compiled. Please run this command to compile it: /layers/heroku_ruby/gems/vendor/bundle/ruby/2.6.0/gems/passenger-6.0.12/bin/passenger-config compile-agent
 - Your Passenger installation is broken or incomplete. Please reinstall Passenger. (-1: Unknown error)

If you shell into the docker image created by pack and run the binary support installs you will see it puts them into /home/heroku instead of the environment defined HOME of /app. Strangely if you run /cnb/lifecycle/launcher passenger-config about support-binaries-dir it says they should be located at /layers/heroku_ruby/gems/vendor/bundle/ruby/2.6.0/gems/passenger-6.0.12/buildout/support-binaries which would also work.

CamJN commented 2 years ago

The HOME environment variable is often unreliable, because for example sudo preserves it. That's why we don't respect it by default.

In general one can use the locations.ini file and set whatever support_binaries_dir one likes.