Passenger thinks I'm on the wrong ruby version? - ruby-on-rails

weird issue. I have passenger installed on an Apache 2 server, and trying to get a Rails application running. First time deploying a rails application, so not really sure what's going on.
Passenger gives me this error:
But the problem is that 1.9.2-p136 isn't even installed on my system. I removed all ruby versions and completely reinstalled ruby with 1.9.3-p448. (I also have 2.0.0 but I default to 1.9.3)
Not seeing how passenger is even recognizing that I am running a build of ruby that doesnt exist on my system.
I'm hoping this is my last obstacle to getting this started. I have dealt with about every issue that I could have trying to get this damn rails app up. I'll tell you, they make up for how easy it is to develop with by making it impossible to deploy.
Thanks all!

1.9.2 is probably the system ruby (or was, at some point). Now, how in the heck Passenger is running on that while simultaneously using gems from an rvm install of 1.9.3...
Anyway, check your Passenger config. Make sure the PassengerDefaultRuby (if present) and PassengerRuby directives are pointing to the correct version; Passenger often gets confused by varying PATHs, and this is especially true with rvm where you may be running a different version in your user shell session than system tools will find on their own.
There's a reason people like solutions like Unicorn, Puma, and Rainbows. ;) Passenger, once you get it compiled and configured, is pretty much fire and forget, but getting to that point can be painful.

Related

How can I open my custom URL-s?

I'm trying to get my homework done in Ruby on Rails, but I have already faced dozens of problems because of my lack of UBUNTU (16.04.1) knowledge.
I have installed all the required gems and other clients like MySQL2, Apache2 and Puma. Puma is running, I have two standard tables in MySQL, but there is some issue with my Apache2 connection. I can access localhost:3000 (it says: Yay! You are on rails now!), but I just cannot reach my custom URL-s, that are located in the 'hosts' file.
Could any of you help me with getting started? I could blow my top because I have a lot of work to do and I cannot get through the basic steps of installing the environment...
Thanks in advance!

Upgrading ruby on a production server with Rails and Passenger

I have a few Rails apps, each running on their own server. They run under Passenger-apache, and currently under ruby 1.9.3. Currently, they run under a ruby installed and managed with rbenv.
I'd like to upgrade them all to ruby 2.2.x. As long as I'm doing this, I'd like to upgrade them from passenger 4.x to 5.x as well.
Let's assume I've tested them all on my development box and am confident they run fine under ruby 2.2.
As I think through this, I get very confused about the best way to do this -- especially with minimal production downtime.
I guess I'd start out by installing ruby 2.2 under rbenv, which theoretically shouldn't disturb the running apps. Passenger is installed under a particular ruby, but then has the option of running apps under different rubies. Should I install the latest passenger first, under the new ruby 2.2, but configured to run the existing apps under the old ruby? And then upgrading the apps to the new ruby... I guess involves running bundle install again, to get all dependencies installed under the new ruby?
Or something else entirely? Is there a way to do this that is relatively safe, and will have limited or zero downtime for my apps?
Has anyone done this before? I'm fairly familiar with all the pieces already, and can brainstorm possible approaches myself, but when I start, there are too many places where I'm not sure what the best approach is. What I could really use is advice from someone who has already done this, or is otherwise pretty sure that what they recommend will work as they say -- not just guesses about things you haven't done that might work. Thanks!
Make sure that your applications work under the new ruby version. I have had some legacy Rails 3.2.x applications that works up to ruby 2.1.5, but breaks in ruby 2.2.x. You should be fine with updating your ruby and passenger versions.
Since each application runs on their own server, you don't have to really worry about running multiple versions of passenger. You should be able to install the new version ruby on each server, install the gems, update apache to the newer passenger and restart apache to have everything take effect. Worst case, you can clone your servers to a virtual environment and test everything prior to doing it on production. This would help you minimize downtime as you would have any workarounds and/or research of bugs done prior to touching the production environment.

Updating Ruby version to newer (latest) on production?

We use Ubuntu 12.04 TLS, Ruby 1.9.3, Rails 3.2.12, and RVM on our production server.
We want to upgrade Ruby from 1.9.3 to 2.2 (or whatever the latest one is), without updating Rails.
I have three questions:
Are there any caveats in doing that, any inconsistensies, deprecated methods? Is there any chance that site will stop working?
Considering that we are using RVM, would it be possible to get back to the version we are using right now (if anything goes wrong)?
Would it be necessary to re-install all the gems that we are using right now?
Thanks in advance!
Always presume the whole machine is going to be trashed beyond repair by this process. Prepare for the worst, hope for the best. If you don't have a test machine, you can build one with a tool like Vagrant. Once you have a procedure that works, repeat it on your production system.
Ruby 2.1.1 is the current version. You'll also want to look at upgrading Rails itself to avoid a bunch of nasty vulnerabilities. 3.2.17 is the version to target here.
RVM does make it easier to upgrade things, but you'll also need to upgrade your launcher (e.g. Passenger) to use the newer Ruby version. Yes, it is possible to back out, but this is not always convenient.
One trick that might help rescue from disaster is checking your /etc directory into a local Git repository. This allows you to rollback any configuration changes you make, as well as see what changes you've actually made through the course of your upgrades.
Any change to the base Ruby version does require re-installing all gems. If you're using Bundler or an automated deployment tool this should be fairly automatic.

Error using Passenger with RVM: "Passenger RequestHandler warning: someone tried to connect with an invalid connect password"

As we (finally) port our apps away from Ruby 1.8.7, I am trying to set up Phusion Passenger and Apache, with RVM, to serve apps using both Ruby 1.87/Rails 2.3.x and Ruby 1.9.3/Rails 3.2.x. This is all on my development machine; in production we us separate VMs to serve the two different platforms--but needless to say, that would be inconvenient in development.
The Good: I've got Passenger 3.0.7 installed using Ruby 1.8.7 (and RVM), and 1.8.7/Rails 2.3.x apps work great as they have in the past (the only thing changed from my past setup is having (re)installed Passenger via RVM).
The Bad: I also have installed Passenger 4.0.20 as a gem using Ruby 1.9.3 (and RVM), and if I configure Apache to use them, it is able to serve up a 1.9.3/Rails 3.2.x app just fine. But Passenger can't serve the Ruby 1.8.7/Rails 2.3.x app.
Another developer here has essentially the same setup working but we are unable to see any clear differences between her installation and mine. But her success tells me it is possible.
The Ugly: When I try to run the 1.8.7/2.3.x app with Passenger 4.0.20, Passenger logs a bunch of output to the Apache error.log, including these lines:
[ 2013-10-22 13:12:30.1770 21240/7fe89ad0e700 Pool2/SmartSpawner.h:301 ]: Preloader for /home/username/workspace/app started on PID 21284, listening on unix:/tmp/passenger.1.0.21232/generation-0/backends/preloader.21284
[ 2013-10-22 13:12:30.2547 21240/7fe89ac8c700 Pool2/Implementation.cpp:1274 ]: [App 21284 stderr] [ 2013-10-22 13:12:30.2547 21385/0x7f9bf1fd0b80(Worker 1) request_handler/thread_handler.rb:197 ]: *** Passenger RequestHandler warning: someone tried to connect with an invalid connect password.
It's the last bit (scroll to the right!) that seems the most bizarre.
Some online searching reveals that Passenger supports some sort of 'connect password' but we are using no such thing. There are few Passenger-related references to 'someone tried to connect with an invalid connect password' outside of the Passenger source code.
I actually have solved this problem, but due to the dearth of references on the web, and my failure to find any mention of the 'invalid connect password' error here on SO, I am posting this to help the next person. I haven't included lots of other log snippets, configuration file contents and the like, because I have already mentioned all the relevant information.
If you think you know the answer, here's your chance to get some more 'reputation'. Otherwise, I'll post my answer in a couple days.
Phusion Passenger author here. The connect password is a security mechanism in Phusion Passenger to prevent unauthorized processes on the local system to connect to the spawned application processes. The connect password is only known to the HelperAgent, the app process and admin tools like passenger-status.
I'm not sure what went wrong in your case. I'd like to analyze your problem more deeply. Could set PassengerLogLevel to 3, trigger the problem, and post the contents of your Apache error log file to the community discussion forum?
I found my answer in a passing remark on the Passenger forum.
Quoting my question, here is the real problem: "I also have installed Passenger 4.0.20 as a gem using Ruby 1.9.3 (and RVM)..."
I was able to solve it by re-installing Passenger 4.0.20 as a gem using Ruby 1.8.7 (and RVM). With this configuration, Passenger is able to serve up both Ruby 1.8.7 and Ruby 1.9.3 applications.
I have read that in addition to its mainly-native code, Passenger uses a bit of Ruby internally, interpreted by whatever version of Ruby it was installed with. Apparently (and wonderfully) this Ruby code is compatible with Rubies as ancient as 1.8.7. Equally wonderful, it will serve up applications with whatever Ruby their PassengerRuby directives specify... but apparently this isn't the case if Passenger is installed using a newer Ruby than the one needed by the application.
Big thanks to the Passenger and RVM teams, and also to Maximilian Herold for solving my mystery.

Installing Ruby Version Manager AFTER ruby on rails installation

This might be a paranoid question, but am I likely to break anything in my ruby on rails app if I install RVM AFTER having installed rails?
Thanks in advance for any peace of mind you can offer me :P
Your App will be fine - but after installing RVM it will take some configuration get everything running back the way it was. This has nothing to do with your app, but with your environment. If you follow the installation instructions EXACTLY then it will not be too difficult.
If you are planning to do this on a production server then be prepared for some downtime.

Resources