Installing JSON Gem with Bundler without GCC - ruby-on-rails

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.

Related

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

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'

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

How do I fix a bad Capistrano deployment?

Made a large update last night and my site is currently down. I used cap deploy:rollback with no luck. The error logs aren't telling me much. The last error I saw when trying to deploy was:
** [out :: website.com] You are trying to install in deployment mode after changing
** [out :: website.com] your Gemfile. Run `bundle install` elsewhere and add the
** [out :: website.com] updated Gemfile.lock to version control.
** [out :: website.com]
** [out :: website.com] You have deleted from the Gemfile:
** [out :: website.com] * asset_sync
command finished in 934ms
My cap tail just says the following with no errors:
Migrating to AddSessionsTable (20120722094547)
Migrating to AddSlugToUserProjects (20120723204816)
Migrating to AddSlugIndexToUserProjects (20120723205558)
Migrating to CreateFriendlyIdSlugs (20120723210904)
Migrating to AddNameToUsers (20120723221700)
Migrating to AddSlugToUsers (20120723222456)
Migrating to CreateComments (20120724203252)
Any help?
Run bundle install on your development server, then cap deploy. Another possible solution: add asset_sync back to your Gemfile.
As last resort, you can run cap -d deploy. It will run deployment step-by-step, asking you for continue on each step. Login to production server in separate shell and do some adjustments between steps manually.
It looks like the Gemfile change didn't go well. How it was fixed:
logged into server, there were 6 ruby processes that were taking all available things. This is almost certainly the unicorn processes trying to start and couldn't… killall -9 ruby
cd into the app's current directory
RAILS_ENV=production bundle exec rake assets:precompile
service unicorn_whimseybox start
It looks like (in the unicorn.log), the error was:
E, [2012-07-26T17:27:10.552912 #24818] ERROR -- : uninitialized constant AssetSync (NameError)
I had the same error after converting some Gemfile source lines into blocks.
The error was due an old Bundler version on production (1.7.3) vs 1.8.3 on development.

Error deploying to rbenv with Capistrano

I'm new to Capistrano and having trouble debugging an error. Searching suggests this error could be an environment issue of picking up the wrong version of ruby (it's almost certainly not the referenced file as it works fine in test). Using a Capistrano task to dump the ruby version everything looks fine. Running the commands directly on the server works fine, too. I'm using rbenv on the server.
The error:
* executing `deploy:assets:precompile'
* executing "cd /home/deployer/apps/happenate/releases/20120424002545 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["happenate.com"]
[happenate.com] executing command
** [out :: happenate.com] rake aborted!
** [out :: happenate.com] /home/deployer/apps/happenate/releases/20120424002545/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
** [out :: happenate.com] ...sion_store :cookie_store, key: '_happenate_session'
** [out :: happenate.com] ^
Definitely some sort of ruby environment issue. After cleaning everything up with a proper rbenv environment, the error is gone.

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

Resources