Phusion Passenger: `Unexpected end-of-file detected.` - ruby-on-rails

I'm trying to get my Rails 3.2.8 app running on justhost.com's web hosting platform and I'm having a few problems. The app works fine on WEBrick when I ssh into the server and run rails server, but passenger (the server platform provided by justhost) is having some issues:
I don't understand what this error means or have any idea on how to fix it. Could someone please point me in the right direction?
In case this information is relevant, here are the contents of my .htaccess file:
PassengerEnabled On
PassengerAppRoot /home3/webgemla/rails_apps/WebGemLabs/
SetEnv GEM_HOME /home3/webgemla/.rvm/gems/ruby-1.9.3-p194
Note: The live version of my app is at webgemlabs.com

When I visited your link I got this error message:
Error message:
no such file to load -- bundler
You probably just need to gem install bundler on your server.

Related

Apache-Passenger can't start my production rails application

I'm new to deploying rails applications and for what I read in many sites the Apache/Passenger combo was one of the simplest ones; however I have encountered that Passenger does not want to start my application and displays the following error message when entering the sudo tail -50 /var/log/apache2/error.log
command:
Could not spawn process for application /home/test/Documents/sites/depot:
An error occured while starting up the preloader.
Message from application: cannot load such file -- bundler/setup (LoadError)
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:406:in
`activate_gem'
...
age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session
because a spawning error occurred. The identifier of the error is 6ce15bbe.
Please see earlier logs for details about the error.
I suspect it has to do with my ruby installation, I used rbenv and got the 2.2.3 version but in the error message it was linking to a 2.0.0 version which I have never installed.
I also suspect that it has something to do with me using this two commands from another guide:
sudo rm /usr/bin/ruby
sudo ln -s /usr/local/bin/ruby /usr/bin/ruby
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04
If anybody know how to fix this headache of a problem I'll really appreciate it.
Thanks!
You probably need to specify correct PassengerDefaultRuby in your httpd.conf file.
My recommendation is to go through the installation of passenger using their official guide:
https://www.phusionpassenger.com/library/install/apache/
After some clues left by #dimakura and #CamdenNarzt I was able to solve this in two stages.
As I suspected Passenger was using the wrong version of ruby, to fix this I modified the passenger.conf file located under /etc/apache2/mods-available/ with the output of the which ruby command:
Added the line (replace with your own which ruby output)
PassengerRuby /home/test/.rbenv/shims/ruby
Restarted apache got a "Incomplete response received from application" error message, checked the logs and noticed that the proper version of ruby was now being used but got an error message:
"Missing secret_token and secret_key_base for 'production' environment, set these values in config/secrets.yml"
Installed the Figaro gem by following the instructions on this site: https://www.twilio.com/blog/2015/02/managing-development-environment-variables-across-multiple-ruby-applications.html then generated a secret key using the command:
rake secret
Copied the output and opened the config/application.yml file where I entered:
SECRET_KEY_BASE: [output key from rake secret command]
Restarted Apache and it worked!!

Rails + Apache + Passenger + EC2 Linux AMI "Incomplete Response From Application"

I am getting served "Incomplete Response From Application" on a fresh install of Apache 2 + Rails 4 + Phusion Passenger. I followed the instructions found here, but as I am no sysadmin, I really was operating mostly blind. At first, when I checked the logs, I was missing a javascript runtime environment. I am guessing passenger is written in JS or something like that, not sure why I would need it, so I added gem 'execjs' to the gemfile and installed nodejs on my linux AMI using sudo yum install nodejs npm --enablerepo=epel The only other deviations I took from that guide were that I changed the default DocumentRoot and Directory in my httpd.conf as I have no server name yet for a vhost. Thanks for your time!
Someone on SO referenced this as a solution:
Enter your app root
run: rake secret
copy the output
go to /yourapp/config/secrets.yml
set the production secret_key_base
This causes the entire app to not respond.
It turns out I had the security group not accepting any connections except from my machine on the RDS database for production.

How do I get Passenger to deploy a RoR app on Ubuntu 12.04 LTS?

I'm trying to get a simple 'hello world' RoR app deployed using Apache/Passenger on Ubuntu 12.04 (via Linode). I followed the directions on the Phusion Passenger documentation site. I get the Passenger error screen that says:
Ruby (Rack) application could not be started
The backtrace is here: http://pastebin.com/Sr4PaQvB
My apache virtual host config is here: http://pastebin.com/q2vb0hX8
One thing that is confusing me is why Passenger is not using the ruby (and gems) that I have installed via RVM even though I specifically use SetEnv and 'PassengerRuby` to tell it where to look. I appreciate any advice! Thanks!
The reason why Passenger wasn't loading up the right ruby/gems was because RVM wasn't installed correctly. I reinstalled RVM and reconfigured my app setup for the correct gems and all was well.

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.

why isn't my rails install using the latest version of passenger?

I'm using VirtualBox on Windows to run an Ubuntu OS, which is running the turnkey rails package, which comes with ruby 1.8, rails 2.3.8, and passenger 2.2.5. When I first booted it up with just a vanilla rails app it worked fine, but now I'm getting the following error:
uninitialized constant PhusionPassenger::Utils::PseudoIO::StringIO
I googled this, and on the phusion/google groups it said this was an old error and to upgrade passenger, which I did with gem upgrade passenger. It said it was installing passenger 2.2.15, but it doesn't appear to be using it. I re-started the whole virtualbox and it is still giving me the same error, with the backtrace showing passenger-2.2.5.
I realize there are several layers here and plenty of places for things to go wrong, and to add to that, I'm pretty much a Linux newb. I've got some experience with rails. I'd appreciate any help.
It could well be your Apache configuration file. When Passenger installs it adds some code to the /etc/apache2/http.conf file so that Apache loads the Passenger extension. This code includes the version number so if you've changed the version of Apache you'll need to modify this file. The code you're looking for looks like this
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /opt/local/bin/ruby
You'll have to be authenticated to edit the file so open a terminal window and type
sudo gedit /etc/apache2/http.conf
and enter your password to edit the file. Once you've made the changes close gedit then run
sudo /etc/init.d/apache2 restart
to restart Apache and try your Rails application again.
Try using
gem list
to make sure the new version was installed. Next to the passenger gem should see more than version listed.
You can use
gem clean
to remove old versions.

Resources