Ruby on Rails: Heroku: How do I get my gems installed? - ruby-on-rails

this is my GemFile
source :rubygems
gem 'rails', '2.3.8'
gem 'authlogic', '2.1.6'
gem 'addresslogic', '1.2.1'
gem 'searchlogic', '2.4.19'
gem 'subdomain-fu', '0.5.4'
but, when I run the app on heroku, I get "App Crashed"
and the log says I only have rails installed, and I need the non-rails gems listed above.
What am I doing wrong?
output from heroku push
% git push heroku master
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 860 bytes, done.
Total 6 (delta 3), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
-----> WARNING: Detected Rails is not declared in either .gems or Gemfile
Scheduling the install of Rails 2.3.8.
See http://docs.heroku.com/gems for details on specifying gems.
-----> Installing gem rails 2.3.8 from http://rubygems.org
Successfully installed activesupport-2.3.8
Successfully installed activerecord-2.3.8
Successfully installed rack-1.1.0
Successfully installed actionpack-2.3.8
Successfully installed actionmailer-2.3.8
Successfully installed activeresource-2.3.8
Successfully installed rails-2.3.8
7 gems installed
Compiled slug size is 11.7MB
-----> Launching.... done
http://%%%%%%%%%%%%%%%%%%%.heroku.com deployed to Heroku
To git#heroku.%%%%%%%%%%%%%%%%%%%.git
3ac597d..b849480 master -> master
heroku log
==> dyno-3334279.log <==
Missing these required gems:
authlogic
addresslogic
searchlogic
You're running:
ruby 1.8.7.253 at /usr/ruby1.8.7/bin/ruby
rubygems 1.3.7 at /home/slugs/362612_b849480_24ac-7763f7d7-8c04-478b-ab13-af81efd3e8c2/mnt/.bundle/gems/ruby/1.8, /home/slugs/362612_b849480_24ac-7763f7d7-8c04-478b-ab13-af81efd3e8c2/mnt/.bundle/gems, /home/slugs/362612_b849480_24ac-7763f7d7-8c04-478b-ab13-af81efd3e8c2/mnt/.gems, /usr/ruby1.8.7/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
==> production.log <==
# Logfile created on Sun Nov 28 19:41:39 -0800 2010

If you have a file named Gemfile (in this exact case/spelling) in the root of your repository, Heroku will use this file to determine all the gems to install.
You mentioned that you have a GemFile - if that is the way the filename is cased in your repository, Heroku may not pick it up.

You should create a file called .gems in your application root. That file should contain a list of the gems you need and the syntax for defining the gem dependencies are like this:
rails --version 2.3.8
authlogic --version 2.1.6
etc...

Related

Mina Deploy "Bundle is locked to rake"

After running
mina deploy
I get this error
mina deploy
-----> Creating a temporary build path
-----> Fetching new git commits
-----> Using git branch 'master'
Cloning into '.'...
done.
-----> Using this git commit
root (e1bd364):
> fixes fo rmina
-----> Symlinking shared paths
-----> Installing gem dependencies using Bundler
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Your Gemfile has no gem server sources. If you need gems that are not already on
your machine, add a line like this to your Gemfile:
source 'https://rubygems.org'
Your bundle is locked to rake (12.0.0), but that version could not be found in
any of the sources listed in your Gemfile. If you haven't changed sources, that
means the author of rake (12.0.0) has removed it. You'll need to update your
bundle to a different version of rake (12.0.0) that hasn't been removed in order
to install.
! ERROR: Deploy failed.
-----> Cleaning up build
Unlinking current
OK
Connection to app.com closed.
! Run Error
If I run bundle show rake I see this
/var/lib/gems/2.3.0/gems/rake-12.0.0
I tried looking in app/vendor and bundler is not there. I tried using bundle install and bundle update.
Update:
I checked and source 'https:rubygems.org' is in my gemfile.
I tried running bundle install deployment
bundle install --deployment
and ran into the same error.
Your Gemfile has no gem server sources. If you need gems that are not already on your machine, add a line like this to your Gemfile:
source 'https://rubygems.org'
Seems like there is no gem source specified in your Gemfile
You may try adding this line at the top of your Gemfile
source 'https://rubygems.org'
and then try again
So the issue had to do with permissions and running as root as the error stated.
I had mina and some of the other gem folders under a different user, while deploying as root. Once I cleared up the ownership of files, and added the user as a root user, mina deployed correctly.

Impossible to deploy app in heroku - it searches ruby 2.0.0p195

I've deploying our app with rails 3.2.13 and ruby 2.0.0p0 without problems in heroku. However, today suddenly I couldn't deploy it. This is the log, it seems the only difference in our project is the version of ruby 2.0.0, which is trying to be installed:
Counting objects: 42, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (25/25), 3.17 KiB, done.
Total 25 (delta 19), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
Ruby version change detected. Clearing bundler cache.
Old: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
New: ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Could not find money-rails-0.8.0 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
It seems that it cannot find the money-rails gem (version 0.8.0), but in localhost is working perfectly, and also until yesterday in heroku. I think it's has to be with the new ruby version as it's the only visible change regarding the gems...
Anyone with the same problem?
Thanks in advance!!
You may not have changed anything but it appears the author of money-rails has yanked 0.8.0 and replaced it with 0.8.1. See http://rubygems.org/gems/money-rails for details.
You would have to do a bundle update and commit Gemfile.lock and redeploy and all should be good.

Bundler doesn't load gem in production rails app

I'm having a problem where a single gem is not being loaded by bundler in a rails app, but only in production - there's no problem using the gem in development mode.
The gem is country_select, and we've tried it with version 1.1.3 and the github repository. The app is using rails 3.2.11.
Proof that the gem exists on the server
The gem is successfully installed by bundler in the production environment:
$ RAILS_ENV=production bundle install
...
Using coffee-rails (3.2.2)
Using country_select (1.1.3)
Using daemons (1.1.9)
...
Your bundle is complete! It was installed into /home/deploy/rails-app/shared/bundle
The gem appears in the shared gem directory that bundler installs to:
$ ls -al /home/deploy/rails-app/shared/bundle/ruby/1.9.1/gems/ | grep country
drwxrwxr-x 3 deploy deploy 4096 Apr 3 08:49 country_select-1.1.3
And the gem is loaded when starting rails from the console:
$ RAILS_ENV=production script/rails c
Loading production environment (Rails 3.2.11)
irb(main):002:0> Gem.loaded_specs.keys.grep /country/
=> ["country_select"]
However...
That same check for the country_select gem in the rails app fails. For example:
class ApplicationController < ActionController::Base
before_filter do
raise Gem.loaded_specs.keys.grep(/country/).inspect
end
#...
end
Spits out [] - i.e. the gem is not loaded. Plus, parts of the application that rely on the gem fail as a result of it not existing.
And finally, the question
Simply adding a require 'country_select' somewhere in the startup means that the gem gets loaded, and the app works. But why isn't bundler doing it with that particular gem, despite the fact that it installs it and adds it to the app's gem directory?
More info about the production environment:
$ rvm -v
rvm 1.18.18 (stable)...
$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
$ gem -v
1.8.25
$ bundle -v
Bundler version 1.3.2
Update: 5th April 2013
The problem seems to have "gone away". After a couple of redeployments, it appears to be working. This is in spite of the fact that the country_select gem hasn't been changed, which is very odd. I'm still looking into exactly what has changed in that time, but I'm puzzled.
try running
RAILS_ENV=production bundle exec script/rails c
I have an app using the same versions and I don't need to require the gem in dev or production. I also tried with your before_filter and got ["country_select"] as expected. So the problem isn't with the gem.
I think you're either monkeying around with the loaded gems in initialization somewhere (unlikely) or there's something going wrong with your setup around the server. Are you starting the server with RAILS_ENV=production bundle exec script/rails server? Can you check the gem path being used by the server includes the shared gem path you mentioned in your question?

Trouble pushing barebones app to Heroku with paperclip gem

We have an app that's been running on Heroku (bamboo) for over a year. When pushing a change yesterday, the push was rejected when it failed to install the paperclip gem. No changes had been made to the gem list up to the point of failure. I tried a brand new, barebones app and got the same result. It seems the bamboo stack has changed in some way. Anybody else experiencing this or know what might be going on?
Here are repro steps:
$ rails temp-app
$ cd temp-app
$ cat >.gems
rails -v 2.3.14
paperclip -v 2.5.0
<control-D>
$ git init
$ git add .
$ git commit -m "init"
$ heroku create --stack bamboo
$ git push heroku master
this is the output:
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Installing gem rails 2.3.14 from http://rubygems.org
Successfully installed activesupport-2.3.14
Successfully installed activerecord-2.3.14
Successfully installed actionpack-2.3.14
Successfully installed actionmailer-2.3.14
Successfully installed activeresource-2.3.14
Successfully installed rails-2.3.14
6 gems installed
-----> Installing gem paperclip 2.5.0 from http://rubygems.org
ERROR: While executing gem ... (NoMethodError)
undefined method `call' for nil:NilClass
! Heroku push rejected, failed to install gem
I did get an answer from Heroku support: Paperclip specifies a dependency on Active Record like this: 'activerecord', '>= 2.3.0' which causes the latest AR version to be installed. The latest version as of a few days ago is 3.2, which is broken on Rails 2.3, hence the failure.
I solved this by adding --ignore-dependencies to the paperclip gem in .gems and manually adding dependencies to .gems.

Heroku Push Error: "sprockets-2.0.0.beta.2 in any of the sources"

I'm tryting to push my RoR 3.1.0.beta1 project up to Heroku from my Git repository using the following command as usual:
git push heroku master
But I am getting the following error:
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for http://rubygems.org/
Could not find sprockets-2.0.0.beta.2 in any of the sources
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
My Gemfile has this line:
gem 'sprockets', '2.0.0.beta.2'
Sprockets version 2.0.0.beta.2 exists because I've been pulling different versions including this version. Is there something I'm missing here?
Thanks
Looks like this version has been pulled from Rubygems, only beta.12 and beta.13 are listed:
http://rubygems.org/gems/sprockets
So you'd need to get the specific beta.2 branch from the repo, as Thariq suggests.
BUT, I'd probably go for one of the versions listed on rubygems - there must be good a reason why they were pulled ;)
It's not on rubygems because:
You need to figure out what source you are getting the gem from and add that to the top of your gem file like so:
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3'
gem 'sprockets', '2.0.0.beta.2'
gem "sprockets", "~> 1.0.2" is on ruby gems. But you will need to find where your versions is specifically hosted such as http://mysite.org add that to the top of your gemfile.
Presumably you've been pulling from the Sprockets Git Repo. You need to tell your Gemfile where you get a gem that's not in rubygems, so in this case you would use:
gem 'sprockets', '2.0.0.beta.2', :git => 'git://github.com/sstephenson/sprockets.git'

Resources