Deploying with Rubber: 'libapache2-mod-passenger' was not found - ruby-on-rails

I am following Ryan Bates's Rails Cast to deploy a Rails app to EC2 with Rubber. Everything seems to go well until this error. How can I fix this?
** [out :: production.foo.com] Ign https://oss-binaries.phusionpassenger.com precise/main Translation-en
** [out :: production.foo.com] Fetched 60.6 kB in 2s (25.7 kB/s)
** [out :: production.foo.com] Reading package lists...
** [out :: production.foo.com]
** [out :: production.foo.com] Reading package lists...
** [out :: production.foo.com]
** [out :: production.foo.com] Building dependency tree...
** [out :: production.foo.com]
** [out :: production.foo.com] Reading state information...
** [out :: production.foo.com]
** [out :: production.foo.com] E
** [out :: production.foo.com] :
** [out :: production.foo.com] Version '1:4.0.48-1~precise1' for 'libapache2-mod-passenger' was not found
** [out :: production.foo.com]
command finished in 10387ms
failed: "/bin/bash -l -c 'sudo -p '\\''sudo password: '\\'' bash -l /tmp/install_packages postfix build-essential git-core libxslt-dev ntp postgresql-client libpq-dev subversion curl autoconf bison ruby zlib1g-dev libssl-dev libreadline6-dev libxml2-dev libyaml-dev apache2 libapache2-mod-proxy-html libcurl4-openssl-dev libapache2-mod-xsendfile apache2-mpm-prefork apache2-prefork-dev libapache2-mod-passenger=1:4.0.48-1~`lsb_release -sc`1 collectd libperl-dev monit postgresql-9.1 openjdk-7-jdk unzip python-django python-django-tagging python-cairo python-memcache memcached uwsgi uwsgi-plugin-python uwsgi-plugin-http sqlite3 bzr zip mongodb-10gen haproxy ec2-ami-tools'" on production.foo.com
My rubber.yml:
app_name: My_App
app_user: app
admin_email: "root##{full_host}"
timezone: US/Western
domain: foo.com
cloud_providers:
aws:
region: us-west-2
access_key: MYACCESSKEYXX
secret_access_key: secret-keyXX
account: MYACCOUNTXXX
key_name: my-key-file
key_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/*' + cloud_providers.aws.key_name].first}"
image_type: t2.micro
image_id: ami-ef5e24df #this is a Ubuntu 12.04 precise EBS hvm 64-bit
Tried what was suggested in this question, but didn't help.
I tried installing libapache2-mod-passenger in both my local machine and amazon's instance, didn't help.
I am using Ruby 1.9.3 to avoid other problems

Ended up changing the passenger version from 1:4.0.48-1~precise1 to 1:4.0.50-1~precise1 in the rubber-passenger.yml and that fixed the problem.

Just an update of it.
You must change in this way:
before
passenger_version: '1:4.0.57-1~`lsb_release -sc`1'
after
passenger_version: '1:5.0.6-1~`lsb_release -sc`1'
What you have to do is just change the number version and get the number version as Derek Hill said

I experienced this same error.
The reason for this problem is expressed by Kevin Menard: “Passenger has this very annoying behavior of removing packages from their index as soon as a new version is released.”
The answer is to update the passenger_version in rubber-passenger.yml, but the question is to what.
The approach that worked for me was obtaining the version from the trusty directory:
Go to https://oss-binaries.phusionpassenger.com/apt/passenger/dists/trusty/main/binary-amd64/Packages
Open the “Packages” file
Find the version of the libapache2-mod-passenger package
In my case that meant updating passenger_version to 1:5.0.5-1~trusty1

I faced the same issue. One by one I tried the version present on above given url
https://oss-binaries.phusionpassenger.com/apt/passenger/dists/trusty/main/binary-amd64/Packages
I found it hectic first and I thought how could I enter all one by one. So I filtered the ones containing keywords "libapache2-mod-passenger" by using chrome ctrl+f search filter, as it highlights the area where this keyword is present.
Fortunately I got this working on this version
'1:5.0.29-1~`lsb_release -sc`1'

Related

capistrano fails to deploy Sprockets::FileNotFound submodule file

I've got a Rails 3.2 app with capistrano 2 installed and I have a number of submodules. I just moved vendor/assets/javascripts/ui-utils to a submodule.
[submodule "app/assets/javascripts/jquery.autotab"]
path = app/assets/javascripts/jquery.autotab
url = git#github.com:map7/jquery.autotab.git
[submodule "app/assets/javascripts/jquery.overdrive"]
path = app/assets/javascripts/jquery.overdrive
url = git#github.com:map7/jquery.overdrive.git
[submodule "app/assets/javascripts/jquery.validationEngine"]
path = app/assets/javascripts/jquery.validationEngine
url = https://github.com/posabsolute/jQuery-Validation-Engine.git
[submodule "app/assets/javascripts/keymaster"]
path = app/assets/javascripts/keymaster
url = git#github.com:map7/keymaster.git
[submodule "vendor/assets/javascripts/ui-utils"]
path = vendor/assets/javascripts/ui-utils
url = github.com:/map7/ui-utils.git
It's only the bottom submodule which I'm having trouble with. Could this be because it's in the vendor/assets area?
Now when I do a cap deploy I get the following error
* executing "cd -- /srv/pais/releases/20140630042430 && RAILS_ENV=production RAILS_GROUPS=assets env RBENV_ROOT=\"/usr/local/rbenv\" PATH=\"/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH\" RBENV_VERSION=\"2.1.1\" /usr/local/rbenv/bin/rbenv exec bundle exec rake assets:precompile"
** [out :: staging.pais.com.au] rake aborted!
** [out :: staging.pais.com.au] Sprockets::FileNotFound: couldn't find file 'ui-utils/modules/keypress/keypress.js'
** [out :: staging.pais.com.au] (in /srv/pais/releases/20140630042430/app/assets/javascripts/application.js:42)
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:102:in `resolve'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:142:in `require_asset'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:215:in `process_require_directive'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:165:in `block in process_directives'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:163:in `each'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:163:in `process_directives'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:97:in `evaluate'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
On my development machine this file does exist and works.
I've tried putting the following into my deploy.rb with no luck
set :git_enable_submodules, 1 # Get submodules
set :git_submodules_recursive, true
namespace :git do
desc "Init & update submodules"
task :update_submodules, :roles => :app do
run("cd #{release_path} && git submodule init && git submodule update")
end
end
before "deploy:assets:precompile", "git:update_submodules"
Update 30/06/14
Noticed that if I go to any of the other submodules and type git status then I get the following;
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
nothing to commit, working directory clean
If I go to my ui-utils submodule and type git status I get
# HEAD detached at 4e86ac7
nothing to commit, working directory clean
I'm running git version 1.9.1, if I run the following
git submodule deinit -f vendor/assets/javascripts/ui-utils
Then try adding it again using
git submodule add git#github.com:map7/ui-utils.git vendor/assets/javascripts/ui-utils
I get the following error
A git directory for 'vendor/assets/javascripts/ui-utils' is found locally with remote(s):
origin https://github.com/map7/ui-utils.git
If you want to reuse this local git directory instead of cloning again from
git#github.com:map7/ui-utils.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
Update
I managed to remove the vendor/assets/javascripts/ui-utils from git completely by following
How do I remove a submodule?
I've now added it again through submodule and now it's like the other submodules but I still get the deploy problem.
Update
If I use cap --debug deploy and stop it just before the error, then I ssh over to my server and do a git status I can see some problems with the submodule and capistrano on the server;
git status
# On branch deploy
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# deleted: log/searchd.test.pid
# modified: vendor/assets/javascripts/ui-utils (modified content)
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# REVISION
# app/assets/javascripts/jquery.autotab/
# log
no changes added to commit (use "git add" and/or "git commit -a")
I found the solution and might keep this here. It was multiple things
I had to completely remove my submodule and add it again correctly
Had to remove set :deploy_via, :remote_cache from my deploy.rb file
cap --debug deploy helped a lot here.

Error when trying to deploy: The bundle currently has capybara locked at 2.2.1

I have a Ruby on Rails web application that I am trying to deploy.
When I try to deploy it, it gets a little ways, and then stops with the following error:
** [out :: rails-rn-dev.sandia.gov] You have requested:
** [out :: rails-rn-dev.sandia.gov] capybara = 2.1.0
** [out :: rails-rn-dev.sandia.gov]
** [out :: rails-rn-dev.sandia.gov] The bundle currently has capybara locked at 2.2.1.
I can't figure out how this is happening. I know that both my Gemfile and my Gemfile.lock files specify capybara version 2.1.0 be used.
So, why is the bundle locking capybara at 2.2.1?
Thanks in advance,
Tim

Installing JSON Gem with Bundler without GCC

I am in the process of deploying a rails application to a server. There are a few environmental limitations, namely:
No internet access on server
No root access on server
No build tools (GCC, etc)
I almost have the capistrano deployment working, however I get a failure when bundler tries to install the json gem:
** [out :: 192.168.7.115] Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
** [out :: 192.168.7.115]
** [out :: 192.168.7.115] /app/ruby/bin/ruby extconf.rb
** [out :: 192.168.7.115] creating Makefile
** [out :: 192.168.7.115]
** [out :: 192.168.7.115] make
** [out :: 192.168.7.115] compiling generator.c
** [out :: 192.168.7.115] make: gcc: Command not found
** [out :: 192.168.7.115] make: *** [generator.o] Error 127
Since there is no internet, I have all of my gems stored in vendor/cache. I wanted to solve this problem by compiling the json gem on a similar machine that does have gcc, but I wasn't able to find a "compiled-looking" gem on the system. Normally, I see a [gemname]-x86_64-linux.gem gemfile that indicates the compilation has already been taken care of. Can't seem to find this for the JSON gem, but if I did, I'm guessing I could just drop it in my vendor/cache folder and call it a day.
Any suggestions? Am I approaching this problem correctly?
I can't recommend this method as it's likely a bad thing on many levels, but it did solve my problem. I ended up copying the shared/bundle folder from the staging server to the production server. Bundler sees that the gems are already installed and doesn't try to reinstall them.

deploying ruby on rails app using capistrano - cap deploy:setup failing

I've wasted a few days on this problem and I'm sure it's a simple solution, please help!
When I run $ cap deploy:setup from my user account on my laptop I get the errors I've pasted below. It seems that there's a problem with RVM, but I know that it's installed, and I've pre-installed all the gems my app will need as well. Has anyone else encountered similar errors? Any help would be hugely appreciated!
* executing `deploy:setup'
* executing "mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids"
servers: ["arbiter.nullpointer.ca"]
[arbiter.nullpointer.ca] executing command
** [out :: arbiter.nullpointer.ca]
** [out :: arbiter.nullpointer.ca] $rvm_path (system_wide) does not exist.
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/scripts/rvm: line 154: __rvm_teardown: command not found
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/bin/rvm-shell: line 74: rvm: command not found
*** [err :: arbiter.nullpointer.ca] Error: RVM was unable to use 'default'
command finished
failed: "rvm_path=system_wide /usr/local/rvm/bin/rvm-shell 'default' -c \"mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids\"" on arbiter.nullpointer.ca
I just ran into this problem though my installation was complaining with:
out :: server]
** [out :: server] $rvm_path (/home/nebula/.rvm/) does not exist.
*** [err :: server] /usr/local/rvm/scripts/rvm: line 185: __rvm_teardown: command not found
*** [err :: server] /usr/local/rvm/bin/rvm: line 52: /home/nebula/.rvm//scripts/rvm: No such file or directory
*** [err :: server] Error sourcing RVM!
*** [err :: server] Error: RVM was unable to use 'ruby-1.9.3-p392'
I am using rvm with a system wide install, (standard install to /usr/local/rvm). Adding the following to my Capfile solved the issue:
set :rvm_type, :system
set :rvm_path, "/usr/local/rvm"
The Error shows: RVM was unable to use 'default' gemset. Means RVM can't find a gemset named 'default' to use. Check the following line in your deploy.rb
set :rvm_ruby_string, 'gemset-name-here' => put a valid gemset here

Why am I getting Permission denied error in deployment on files generated by capistrano?

I was having a failed: "sh -c 'cd /var/www error. Then fixed it by adding the following in deploy.rb...
set :default_environment, {
'PATH' => "/var/lib/gems/1.9.1/bin:$PATH"
}
Now I'm getting this new error.
** [out :: ip.address] Rails Error: Unable to access log file. Please ensure that /var/www/releases/20111208152807/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
** [out :: ip.address] mkdir -p /var/www/releases/20111208152807/public/assets
** [out :: ip.address] mkdir -p /var/www/releases/20111208152807/public/assets
** [out :: ip.address] mkdir -p /var/www/releases/20111208152807/public/assets
** [out :: ip.address]
** [out :: ip.address] mkdir -p /var/www/releases/20111208152807/public/assets
** [out :: ip.address] mkdir -p /var/www/releases/20111208152807/public/assets
** [out :: ip.address]
** [out :: ip.address] rake aborted!
** [out :: ip.address]
** [out :: ip.address] Permission denied - /var/www/releases/20111208152807/public/assets/manifest.yml
So I checked the permissions on manifest.yml and production.log with ls -lha and yes, they're owned by root.
The capistrano deployment is being done by a linux user (not root) that owns the /var/www directory. I'm guessing it's because whatever command is creating those files is giving them root ownership.
CLARIFICATION:
I know that probably just deploying using root will fix the problem but I don't want to use root.
You should never have web application files owned by root, They should be owned by a non privileged user. While the user varies between web servers and how your web server is set up generally the user is www-data (for Apache) or nobody (for Nginx).
And to remove your error you want to run the command mentioned in the error:
chmod 0666 /var/www/releases/20111208152807/log/production.log will set the file to read write permissions for every user.
Those permissions may be a bit permissive so you can restrict them if you feel the need.

Resources