Unicorn not happy with my rack version? - ruby-on-rails

I have been repeating this tutorial for weeks now:
https://www.digitalocean.com/community/articles/how-to-1-click-install-ruby-on-rails-on-ubuntu-12-10-with-digitalocean
Here are the specifics of my project:
I am using Mongoid with database.yml production set to my tested and working Droplet (DigitalOcean VPS) running MongoDB.
My gem file is here, I am new to Rails and am not quite sure if it's set up right, so I just moved them all to assets hoping Unicorn might serve these gems for me?
source 'https://rubygems.org'
gem 'rails', '3.2.14'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'redcarpet', '1.17.2'
gem 'uglifier', '>= 1.0.3'
gem "will_paginate_mongoid"
gem 'will_paginate', '~> 3.0.5'
gem 'will_paginate-bootstrap'
gem 'devise'
gem 'jquery-rails'
gem "mongoid", "~> 3.0.0"
end
Here's what I did:
I used DigitalOcean's 1 click installer. Then I used FileZilla to SFTP into the credentials they provided me with. I deleted all the files in /home/rails and put my new files in from my project. Then I executed bundle install, and restarted the unicorn service. In the tutorial I had seen I can track the log of unicorn, so I executed this: tail -f /home/unicorn/log/unicorn.log
Here is the output which concerns me:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated rack 1.5.2, but your Gemfile requires rack 1.4.5. Using bundle exec may solve this. (Gem::LoadError)
I saw some other solutions to this, all failed. Here are the solutions I tried:
Deleting my Gemfile.lock, and re bundle installing it. Going into the file and removing where it said rack. Running bundle install --binstubs. Restarting the unicorn service with bundle exec before it. The error remains the same.
I've had many different errors before, but I feel this is the closest I have gotten. If someone could explain this to me (I'm new to Rails and would like a thorough explanation) and possibly help me fix the error that would be fantastic and end this frustration.

Just a wild guess
gem "rack", "~> 1.4.5"
May work for you, then of course bundle install afterwards.

This solves the problem:
gem uninstall rack -v 1.5.2

Possibly reload your Ubuntu installation from the DigitalOcean control panel, then try and install Ruby on Rails with Apache and Passenger?
Install RoR
Install Passenger (skip to passenger installation)
You will have errors when first creating your site with rails new as it will try and use SQL when it won't be installed, if you wish to use MongoDB

Related

Phusion error: undefined method `has?' for Sass::Util:Module

I get the following error issued by Phusion when loading a web page:
There was an error while trying to load the gem 'compass-rails'.
Gem Load Error is: undefined method `has?' for Sass::Util:Module
Did you mean? hash
Hash
Backtrace for gem load error is:
/Volumes/Data/htdocs/zetcho/vendor/bundle/gems/compass-0.12.2/lib/compass/sass_extensions/functions/urls.rb:5:in `has?'
The code at the indicated location is:
module Compass::SassExtensions::Functions::Urls
def self.has?(base, instance_method)
Sass::Util.has?(:instance_method, base, instance_method)
end
My gem file contains:
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Compass for stylesheets
gem 'compass-rails'
# Use the Compass extension susy
gem "sprockets"
gem 'susy'
I've just created the Ruby on Rails site using Rails 5.1.2 and ruby 2.3.1. I have a much older site that works fine with the gem. Did I miss a step in the overall install or is this a bug with compass-rails?
I got the same error when I tried to add a controller:
rails generate controller home index
After more digging around, I found a similar problem. I fixed this one by changing the gem file to:
gem 'compass-rails', github: 'Compass/compass-rails'
Then:
rm gemfile.lock
bundle
It seems that the issue can be found in compass-rails 2.0.0. The version 3.0.2 seems to fix this issues. So a possible solution is :
# Gemfile
gem 'compass-rails', '~> 3.0.2'
Then bundle update compass-rails
This avoids targeting the compass-rails git master branch in favor of an actual release.
I came here having the same issue with a grunt compiling issue trying to use Compass/Sass, if this might help someone, my issue was caused because I had an updated version of Sass (sass-3.7.4) that was higher that the max-version compatible with compass, I uninstalled sass:
gem uninstall sass
Which in turn uninstalled compass, and reinstalled compass letting it choose the right version, and problem solved.
gem install compass

Heroku deployment stalls with my rails app, any suggestions?

I'm trying to deploy an app to heroku. I'm running an ubuntu VM. I just had a lot of trouble getting postgres set up, but I think I'm good to go with that.
I've run
heroku create
and i've committed the most recent changed upon my master branch. When I run bundle install - everything is ok. And when I run
git push heroku master
Everything is smooth, including the installing of the gems. Until I reach the line
------> Writing config/database.yml to read from DATABASE_URL
Everything stalls and I'm greeted with this message 15 minutes later
Timed out compiling ruby app (15 minutes)
for good measure here is my database.yml code
development:
adapter: postgresql
database: saasbook
pool: 5
password:
And here is my gem file
gem 'rails', '4.0.2'
gem 'rails_12factor' , group: :production
gem 'pg'
gem 'saas-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'oauth2'
gem 'figaro'
gem 'rake'
gem devise'
gem 'bootstrap-sass'
gem 'rails_layout'
gem 'zxing'
gem 'rmagick'
gem 'carrierwave'
gem 'rqrcode_png'
ruby "2.0.0"
The heroku deployment tutorial stated to insert the line ruby "2.0.0" after bundle install, and before the commit. I am currently running ruby 1.9.3 if that matters/ would have a conflict.
Any suggestions would be a huge help! thanks!
Edit
I'll leave this out here in case this problem ever arises again for someone
Alas, heroku doesn't like java/C dependent gems, and the QR decoding gem ZXING cannot be used on heroku, that was the reason it was stalling.
For starters, you're missing a quote in your Gemfile for devise:
gem devise' should be gem 'devise'
I would also recommend moving the ruby "2.0.0" line to the top of the Gemfile. It may not matter, but it's worth a shot.
Could be a network issue. Be sure the network you are using has all the appropriate ports open for GIT and heroku. You will need more than port 80.
I am sure you solved this already but for ref:
Make sure that your IDE (mine is RubyMine) is not open on that project or the build will stall/fail.

Libv8 & therubyracer - Full install on every new site deployment?

I have a Ubuntu 12.04 server and several rails 3.2.14 sites on it. Every time I do a new site deployment (via capistrano) the first install takes 20 - 30 minutes because it does a full install of libv8, even though I have already installed the libv8 gem on the machine (and see it when I do a gem list).
I've tried the binary version and tried changing versions of therubyracer.
Here's therubyracer part of my Gemfile
group :assets do
gem 'sass-rails', '~> 3.2.6'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '>= 1.0.3'
gem 'therubyracer', '~> 0.12.0'
end
I've turned on verbose output in Capistrano and here's where it hangs up for ~20 minutes
** [out :: 198.58.99.7] Installing libv8 (3.16.14.3)
Any suggestions? Really tired of new sites taking this long to deploy.
As I said in my comment, bundle with the --deployment flag (as Capistrano does) installs gems into a your_app/shared/bundle. One of the reasons for this isolation and location is because the user you're deploying with may not have access to install gems to a system location, and more reasons described here (under the Deploying Your Application heading).
I believe there are ways to force bundler to use the system gems but I don't have any first hand experience of it; see here.
There's probably a conflict in dependencies in your Gemfile.
Remove the version constraint for therubyracer in your Gemfile and bundling should be much faster.
gem 'therubyracer'

ActiveAdmin asset issues in Rails 3.1

I've been trying to get ActiveAdmin to work with my Rails 3.1.1 application. It mostly works until I was looking at the web developers console and noticed images weren't being loaded:
GET http://localhost:3000/images/active_admin/datepicker/datepicker-nipple.png 404 (Not Found)
I came across some people with similar problems, pointing out the url should have been generated with 'assets' not images. I tried the recommendations I found to update the 'sass-rails' gem but I had no luck.
I tried to start a brand new application from scratch with Rails 3.1.1 (the original app was Rails 3.1.0 not sure if the upgrade made the difference then a fresh start) and did the recommended fixes first and now every image loads fine. I tried to copy the similar part of the Gemfile back but it didn't seem to fix my actually application's problem. This is the area around the related lines in my Gemfile:
gem 'sass-rails', '~> 3.1.4'
gem 'meta_search', '>= 1.1.0.pre'
gem 'activeadmin'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Any tips?
Fixed this by completely uninstalling gems and deleting the gemset I was using with RVM for this project and redoing everything in a new version of rails (2.3). Following a similar issue on github leads me to believe this isn't an issue in a new release of ActiveAdmin but this was my solution.

Rails has disappeared

I developed a web in rails and it was working perfectly for months. Now I went to my web folder and started "rails server" but got the reply:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
I really don't understand how rails could disappeared from my system, I am sure I haven't removed it. I was using rails 3.1 on a Mac. Any clues or suggestions?
Gemfile:
source 'rubygems.org';
gem 'rails', '3.1.0.rc5'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#group :test, :production do
# gem 'mysql', '5.1.58'
#end
#group :development do gem 'sqlite3'
#end
#gem install activerecord-mysql-adapter
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-rails', "~> 3.1.0.rc"
gem 'uglifier'
end
gem 'jquery-rails'
I have faced a similar problem.
I believe rails 3.1.0 is buggy, i myself tried my hands on it and reverted back to the stable version of rails i.e. anything but 3.1.0. It would have been better if you have installed RVM. With RVM you can have one or more rails version, in fact an entire gemset.
I myself have a global gemset and another gemset named rails1.
rvm gemset create gemset_name
Once you install the like of ruby and rails version you can set it default
rvm gemset default#gemset_name
I did this back then and it works fine on my end. More on RVM
Hope it helps.

Resources