Trouble pushing barebones app to Heroku with paperclip gem - ruby-on-rails

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.

Related

Heroku gem shows up despite having heroku toolbelt

in my project folder, when I run heroku version, I get heroku-gem/3.32.0 (x86_64-linux) ruby/2.2.0 as one of the items, however in my home folder running the same command returns heroku-toolbelt/3.42.50 (x86_64-linux) ruby/2.2.0. How can I use heroku toolbelt in my project folder?
Solution would be to uninstall the heroku gem like : gem uninstall heroku
and Upgrade Heroku Toolbelt.

Cannot install state_machines gem in Windows environment

I am new to Rails and would like to check how Spree ecommerce solution looks like before the customization. That's why I installed Ruby from RubyInstaller, DevKit, Rails, Spree etc.
During installation of state_machines gem, below error appears and the gem is eventually not installed.
C:\>gem install state_machines
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/gems/state_m
achines- 0.2.2/test/unit/node_collection/node_collection_after_being_copied_test.rb
This has impact on the bundle install of spree project later on:
Errno::EINVAL: Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/g
ems/state_machines-0.2.2/test/unit/node_collection/node_collection_after_being_c
opied_test.rb
An error occurred while installing state_machines (0.2.2), and Bundler cannot
continue.Make sure that `gem install state_machines -v '0.2.2'`
succeeds before bundling.
Current ruby version installed is:
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32] + devkit
rails version is 4.2.0
I am running on Windows environment, without any possibility to move to Linux.
I ran into this too.
Looks like state_machines has some test case files that have a newline in the name.
I'd bet that is the cause of the issue.
I've submitted a pull request over here: https://github.com/state-machines/state_machines/pull/11
In the meantime, my branch doesn't have the issue: https://github.com/jeff-hamm/state_machines
The specific fix (for the moment, until the pullrequest is accepted) is:
git clone https://github.com/jeff-hamm/state_machines
cd state_machines
bundle gem state_machines
rake install
After doing that, 'gem install spree_core' worked just fine on windows.
Keep in mind I am not planning on keeping my branch up to date (I will delete it if the request is accepted), so, that clone url won't be ideal for long

"sqlite3.h" missing when pushing Rails app to Heroku

I'm following this tutorial, but it fails when I try to push to Heroku. It seems "sqlite3.h" is missing. I'm new to development so I'm not sure what information will help people diagnose the problem, so here's everything :). I'm running on Mac OS X 10.7 Lion. Here are the versions of everything I'm working with:
Amits-MacBook-Air-2:demo_app amitgupta$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
Amits-MacBook-Air-2:demo_app amitgupta$ rails -v
Rails 3.2.3
Amits-MacBook-Air-2:demo_app amitgupta$ sqlite3 -version
3.7.11 2012-03-20 11:35:50 00bb9c9ce4f465e6ac321ced2a9d0062dc364669
Amits-MacBook-Air-2:demo_app amitgupta$ heroku -v
2.25.0
Amits-MacBook-Air-2:demo_app amitgupta$ port -v
MacPorts 2.0.4
Entering interactive mode... ("help" for help, "quit" to quit)
[RailsApps/demo_app] > quit
Goodbye
When I try to push to Heroku:
Amits-MacBook-Air-2:demo_app amitgupta$ heroku create --stack cedar
Creating floating-stream-8009... done, stack is cedar
http://floating-stream-8009.herokuapp.com/ | git#heroku.com:floating-stream-8009.git
Amits-MacBook-Air-2:demo_app amitgupta$ git push heroku master
Here's what I get:
Counting objects: 119, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (104/104), done.
Writing objects: 100% (119/119), 33.74 KiB, done.
Total 119 (delta 17), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.2
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Installing rake (0.9.2.2)
.
.
.
Installing sqlite3 (1.3.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
.
.
.
--disable-local
Gem files will remain installed in /tmp/build_2l2dn7bx7lu34/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection.
Results logged to /tmp/build_2l2dn7bx7lu34/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
An error occured while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
To git#heroku.com:blazing-mountain-3659.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:blazing-mountain-3659.git'
When I do:
Amits-MacBook-Air-2:demo_app amitgupta$ sudo port install sqlite3 +universal
I get:
Password:
---> Computing dependencies for sqlite3
---> Cleaning sqlite3
Next I tried:
Amits-MacBook-Air-2:demo_app amitgupta$ sudo gem install sqlite3 -v '1.3.6'
And get:
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.6
1 gem installed
Installing ri documentation for sqlite3-1.3.6...
Installing RDoc documentation for sqlite3-1.3.6...
Then:
Amits-MacBook-Air-2:demo_app amitgupta$ bundle install
gives:
Using rake (0.9.2.2)
.
.
.
Using sqlite3 (1.3.6)
Using uglifier (1.2.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Then I try pushing to Heroku again, but get the same problem. Perhaps it has something to do with the discrepancy between the first command "Creating floating-stream-8009" and the second command "failed to push some refs to 'git#heroku.com:blazing-mountain-3659.git'"?
gem 'sqlite3', :group => [:development, :test]
group :production do
gem 'pg'
end
edit Gemfile as above
remove Gemfile.lock
run bundle install --without production
git add .
git commit -am "bundle updating sqlite3"
git push heroku master
Heroku uses postgresql so you want to remove sqlite3 or move it into a development group in your Gemfile.
Check you Gemfile.lock for any other gems that may have dependencies on sqlite3, as this can also cause problems.
I had a similar problem and I wasn't even using sqlite3 for anything but after removing it from the gem file I still got that error
what solved it for me was a commit command
git commit -am
that I found on this tutorial
What happened to me was, I was following along the Heroku tutorial and when I used git push heroku master it was pushing from my latest Git commit (obviously!)
What I forgot was that in the eyes of Git, I was still using sqlite in the gemfile! Silly me!
So I used git add . followed by a git commit -m "Changed to Postgres." so Git knew about these changes. Pushing after that worked fine for me.
Yes, as these answers suggest, most of the time you will want to avoid using SQLite in production due to the constraints of the Heroku platform. However, you may have a perfectly acceptable use case (ex. read-only config) for using SQLite anyway. My recommendation is to:
Add the heroku-buildpack-apt buildpack
Add to your Aptfile:
libsqlite3-dev
libsqlite3-0

Deploying rails app on heroku

I'm learning RoR and trying to deploy my test app to heroku receiving next error:
Unresolved dependencies detected; Installing...
Using --without developmen
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
You have added to the Gemfile:
* therubyracer (~> 0.9.3.beta1)
* pg
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
Please! Help!
Have you committed your Gemfile.lock?
bundle install
git add Gemfile.lock
git commit -am "Add lock file"
git push heroku master
This error might be because you did not completely do bundle install.
First do
bundle install
Add gem 'pg' to the gem file and install the postgres gems and postgres on your local machine. If you dont want to install postgres on your local machine then add gem 'pg to production environment and run bundle install without test environment. Though heroku discourages this way of running your application. It is always better to use same database for running locally and in production. Installing postgres is pain but it is worth it.
Your ruby should be 1.9.2.
After installing all the dependencies and post gres on your machine do bundle install and add your gem file to heroku.
git add Gemfile
git add Gemfile.lock
git commit
git push heroku master

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

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...

Resources