I have a legacy app deployed to Heroku that is suddenly failing to compile. It works fine locally, and had no problems when I last deployed it on 3/23. Now I'm trying to push a small change - a single link added to a view.
I know this app is using unsupported versions of Ruby / Rails / Spreecommerce - 1.9.3 / 3.0.20 / 0.60. We have plans to update, but in the meantime I need to get this change live.
The error from Heroku is:
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
That rake task completes locally. I double checked the Rakefile, but don't see any issues there. It also been updated in 4 years and hasn't been a problem for multiple deploys per month in the meantime. There also haven't been any Gemfile changes in 6 months and I've confirmed the app runs locally.
Here's my Gemfile (with an obfuscated personal repo of a previous dev):
1 source 'http://rubygems.org'
2
3 ruby "1.9.3"
4
5 gem 'rails', '3.0.20'
6
7 # Generic gem dependencies first
8 gem 'rake', '0.8.7'
9 gem 'aws-s3', :require => 'aws/s3'
10 gem 'dynamic_form'
11 gem 'heroku'
12 gem 'memcache-client'
13 gem 'net-sftp', '~> 2.0.5'
14 gem 'net-ssh', '~> 2.0.9'
15 gem 'fastercsv'
16
17 # Followed by spree itself first, all spree-specific extensions second
18 gem 'savon', '0.9.7'
19 gem 'spree', '0.60.4', :git => 'git://github.com/[some_dev_personal_repo]/spree.git'
20 gem 'spree_heroku', '1.0.0', :git => 'git://github.com/paxer/spree-heroku.git'
21 gem 'spree_advanced_cart', :git => 'git://github.com/romul/spree_advanced_cart.git', :branch => '0-60-x'
22
23 gem 'rack-timeout'
24
25 # Dev/Test/Stage/Prod gems
26 group :production, :staging do
27 gem 'pg'
28 #gem 'rails_12factor'
29 end
30
31 group :development, :test do
32 gem 'sqlite3'
33 gem 'webrat'
34 gem 'cucumber-rails'
35 gem 'rspec-rails'
36 end
And here's my Rakefile (minus identifying namespace):
1 # Add your own tasks in files placed in lib/tasks ending in .rake,
2 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
4 require File.expand_path('../config/application', __FILE__)
5 require 'rake'
6
7 [namespace]::Application.load_tasks
Schneems at Heroku got to the bottom of this. Although there'd never been a version of the rack-timeout version of this app specified, that was the root of the problem.
I believe at some point as well the Gemfile.lock file was generated on a Windows machine, which was keeping Heroku couldn't reuse my lock file (this predates me - I've only ever deployed using OS X).
I specified gem 'rack-timeout', '0.3.2', ran bundle install, and lo and behold the deploy was successful.
Many thanks to Schneems!
Related
I have a sinatra server, and according to the gemfile, there are different groups of gems. Specifically, there is an application group, a testing group, and a development group. How do I switch my application between these three groups? Specifically, I want to be running my server in testing mode so I can do TDD.
Here is the gemfile.
source 'https://rubygems.org'
ruby '2.0.0'
gem 'sinatra'
gem 'sinatra-contrib', require: %w(sinatra/config_file)
gem 'thin'
gem 'slim'
gem 'sinatra-assetpack'
gem 'zurb-foundation'
gem 'compass'
group :application do
# Here should be all the specifics for the application
end
group :test do
gem 'rspec'
gem 'coveralls'
gem 'capybara'
gem 'rubocop'
end
group :development do
gem 'rake'
gem 'guard', '2.2.3'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'guard-livereload'
gem 'guard-shotgun', git: 'git#github.com:rchampourlier/guard-shotgun.git', branch: 'master'
gem 'blam'
end
Gem Groups
Bundler installs by default everything. What you probably want is something like this:
$ bundle install --without test development
for your productive server, this install everything except the test & development group.
source: http://bundler.io/v1.3/groups.html
Sinatra Environment
Since you mentions sinatra explicit you maybe also interested in the sinatra config blocks
# run only in development environment
configure :development do
use Rack::Session::Pool, :key => '', :expire_after => 60 * 10
end
# run only in test environment
configure :test do
use Rack::Session::Pool, :key => 'session', :expire_after => 60 * 60
end
# run everytime
configure do
MongoMapper.database = 'food'
User.ensure_index(:username)
Product.ensure_index(:rnd)
end
You can set the different environments with RACK_ENV.
example:
RACK_ENV=test ruby mytest.rb
source: http://www.sinatrarb.com/configuration.html#built-in-settings
Running Rails 4 on Apache2 using Phusion Passenger and Ruby 2.1 installed via RVM. When I access the Rails app in the browser, I get this error:
Gemfile syntax error compile error
on line 24: syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0', group: :doc
^ (Bundler::GemfileError)
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/dsl.rb:35:in `eval_gemfile'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/dsl.rb:10:in `evaluate'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/definition.rb:25:in `build'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler.rb:154:in `definition'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler.rb:117:in `setup'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/setup.rb:17
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:263:in `run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158
Error ID
506682d5
Rails app gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
the command
cat $(which bundle)
gives
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
gem 'bundler', version
load Gem.bin_path('bundler', 'bundle', version)
command
rake about
gives
About your application's environment
Ruby version 2.1.3-p242 (x86_64-linux)
RubyGems version 2.2.2
Rack version 1.5
Rails version 4.1.6
JavaScript Runtime Node.js (V8)
Active Record version 4.1.6
Action Pack version 4.1.6
Action View version 4.1.6
Action Mailer version 4.1.6
Active Support version 4.1.6
Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, # <ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000004ec86d8>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root /var/www/board/demo
Environment development
Database adapter sqlite3
Database schema version 0
I have no idea where to even start with this one.
Any help is greatly appreciated. Thanks in advance.
Turns out it was an issue with Passenger on RVM, wherein Passenger was using the wrong ruby binary.
After making sure I was using the right Ruby in RVM via
ruby use 2.1
then checking that I was using the proper PassengerRuby directive in Apache using
passenger-config --ruby-command
then changing the Apache configuration to the result of the above command:
PassengerRuby /home/<user>/.rvm/gems/ruby-2.1.3/wrappers/ruby
everything worked.
Well, almost. I encountered another error: a missing SECRET_KEY_BASE ENV. To fix that, I added to the /etc/apache2/envvars the following line:
export SECRET_KEY_BASE=<thisisthesupersecretsecretkeypleasedontcopy>
And restarted apache. Now my only problem is the following error, which I hope has a basic fix:
The page you were looking for doesn't exist.
Alright, I'm new to this and really need some guidance here.
I cannot deploy to Heroku to save my life and have been at it for 8 hours and read every stackoverflow and google post I can find.
Ruby Version ----> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
Rails Version ----> Rails 4.0.0
PostgreSQL ----> psql (PostgreSQL) 9.3.4
Here's what I have going on:
$ git push heroku master
Initializing repository, done.
Counting objects: 62, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (62/62), 14.40 KiB | 0 bytes/s, done.
Total 62 (delta 3), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Installing...etc etc etc
Now I get this...
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Bundle completed (11.95s)
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile.
This is what my Gemfile looks like:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
gem 'rails_12factor', group: :production
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
end
And here is my database.yml
development:
adapter: postgresql
database: rails_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: rails_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: rails_production
pool: 5
timeout: 5000
Type this in your command line: 'gem list'... Let me know if you see 'sqlite3' in the returned list of gems.
Also, put rails_12factor inside your production bloc like so:
group :production do
gem 'pg'
gem 'rails_12factor'
end
Also, add this gem to your development group, and make sure you run bundle install after:
gem 'factory_girl_rails', '~> 4.0'
To minimise differences between development and production (Heroku) I used the Postgresql database in all my environments.
This problem has been bugging me for hours already. I am deploying a Rails3 App in a shared hosting site. I have been able to run the site on my local Ubuntu. It works well. But as I try to deploy it online, it does not work well. So I think it may have something to do with the versions. Also, I am not using this gem in any of my modules. The error message is as follows:
A source file that the application requires, is missing.
It is possible that you didn't upload your application files correctly. Please check whether all your application files are uploaded.
A required library may not installed. Please install all libraries that this application requires.
Further information about the error may have been written to the application's log file. Please check it in order to analyse the problem.
Error message:
No such file to load -- FasterCSV
Exception class:
LoadError
Backtrace:
# File Line Location
0 /home/dev/project/vendor/bundle/ruby/1.8/gems/activesupport-3.1.4/lib/active_support/dependencies.rb 306 in `depend_on'
1 /home/dev/project/vendor/bundle/ruby/1.8/gems/activesupport-3.1.4/lib/active_support/dependencies.rb 214 in `require_dependency'
2 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/engine.rb 417 in `eager_load!'
3 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/engine.rb 416 in `each'
4 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/engine.rb 416 in `eager_load!'
5 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/engine.rb 414 in `each'
6 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/engine.rb 414 in `eager_load!'
7 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/application/finisher.rb 51
8 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/initializable.rb 30 in `instance_exec'
9 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/initializable.rb 30 in `run'
10 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/initializable.rb 55 in `run_initializers'
11 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/initializable.rb 54 in `each'
12 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/initializable.rb 54 in `run_initializers'
13 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/application.rb 96 in `initialize!'
14 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/railtie/configurable.rb 30 in `send'
15 /home/dev/project/vendor/bundle/ruby/1.8/gems/railties-3.1.4/lib/rails/railtie/configurable.rb 30 in `method_missing'
16 /home/dev/project/config/environment.rb 15
17 config.ru 3 in `require'
18 config.ru 3
19 /home/dev/project/vendor/bundle/ruby/1.8/gems/rack-1.3.6/lib/rack/builder.rb 51 in `instance_eval'
20 /home/dev/project/vendor/bundle/ruby/1.8/gems/rack-1.3.6/lib/rack/builder.rb 51 in `initialize'
21 config.ru 1 in `new'
22 config.ru 1
Ruby -v returns
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
Rails -v returns
Rails 3.1.4
I am deploying the app using Phusion Passenger.
Any help will do. Thanks in advance.
Update:
Here's the config.ru
require ::File.expand_path('../config/environment', __FILE__)
run project::Application
Environment.rb
# Load the rails application
#require 'will_paginate'
require 'rubygems'
require 'composite_primary_keys'
require 'logger'
require 'json'
#require 'composite_primary_keys'
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Dealmap::Application.initialize!
Rails.logger = Logger.new(STDOUT)
Gemfile:
source 'http://rubygems.org'
gem 'rails'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '0.3.11'
#gem 'typus'
gem 'nokogiri'
gem 'geokit'
gem 'composite_primary_keys'
gem "rake", "0.8.7"
gem 'geocoder'
gem 'htmlentities'
gem 'json'
gem 'execjs'
gem 'therubyracer'
gem 'activeadmin'
gem "meta_search", '>= 1.1.0.pre'
gem "nifty-generators", :group => :development
gem 'fastercsv'
gem 'gmaps4rails'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
gem "mocha", :group => :test
NOTE: I explicitly changed the project name to 'project'. Also, I recently added the gem 'fastercsv' line in the Gemfile after the error showed.
Thanks a lot!
I asked for help from the support. It seems that the error was that I was pointing to the wrong app version in my .htaccess.
Problem was solved.
I am relatively new to rails and have been working my way through the Michael Hartl Tutorial. Throughout I have been deploying my projects to Heroku, however now I am at the end of chapter 5, I am getting an "application error". Specifically I am getting the following errors when I look into my Heroku logs:
2012-01-04T03:05:04+00:00 app[web.1]: Could not find activemodel-3.2.0.rc1 in any of the sources
2012-01-04T03:05:06+00:00 heroku[web.1]: State changed from starting to crashed
2012-01-04T03:05:06+00:00 heroku[web.1]: Process exited
2012-01-04T03:05:11+00:00 heroku[router]: Error H10 (App crashed) -> GET floating-stone 5077.heroku.com/ dyno= queue= wait= service= status=503 bytes=
Earlier in the log I see the following errors as well:
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/rails-3.2.0.rc1.gemspec'
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionmailer-3.2.0.rc1.gemspec'
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionpack-3.2.0.rc1.gemspec'
my gemfile is as follows:
source 'https://rubygems.org'
gem 'rails', '3.2.0.rc1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.0'
gem 'coffee-rails', '~> 3.2.0'
#gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'rspec-rails', '2.7.0'
gem 'ZenTest', '4.6.2'
gem 'autotest-growl'
gem 'autotest-fsevent'
gem 'webrat', '0.7.3'
end
group :test do
gem 'rspec', '2.7.0'
gem 'webrat', '0.7.3'
end
I am having trouble debugging the issue and looked through almost all of the rails/heroku posts I could find but nothing on this specific issue. I was looking for some help...apologies if this is something quite basic.
I should also mention that the app works fine on my local machine and here is my database information (I am using mysql). Here is the DB info.
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
Thanks!
The live version of new rails is available now ... i think you should give a try to rails 3.1.3 mature version ... this seem to come configuration issue as i am running my apps perfectly with rails 3.1.3 in heroku.
Does your Gemfile.lock file mention this version of ActiveModel? Have you done a full bundle update rails / bundle install, then committed the file and re-deployed?
I had this same problem. What worked in development locally, did not work when I deployed to Heroku. It is likely that you have a gem that is locked to an older version of Rails (or ActiveSupport as was my case.) Review your Gemfile.lock file. You may will likely find a reference to an older version of a Rails component.
Should you find this to be true, try commenting out the gem and see if your app will run when you deploy to Heroku. If so, then review the GitHub forks of the offending gem to see if someone has a solution. If you find an alternative, specify the git repository in your gem file and then run bundle install.
e.g.
gem 'tinymce-rails', :git => 'git://github.com/spohlenz/tinymce-rails.git'