Heroku Failed to Install gems via bundler error with Publify - ruby-on-rails

I am trying to host a RoR app with Publify gem via heroku. However I keep getting the following error. I have followed the instructions on Publify's github page concerning heroku, https://github.com/publify/publify. Another interesting thing is that it runs perfectly on my own server (rails s), signalling that something is wrong with the environment in the gemfile.
Thanks in advance for your help.
Here are the errors I am receiving (heroku push) :
Your version of git is 1.9.3. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
Checking for app files to sync... done, 590 files needed
Uploading: 100.0% (ETA: 0s)
Launching build process... done
Preparing app for compilation... done
Fetching buildpack... done
Detecting buildpack... done, Buildkit+Ruby
Fetching cache... empty
Compiling app...
Compiling for Ruby
Compiling Ruby/Rails
sh: Syntax error: Unterminated quoted string
!
ERROR: There was an error parsing your Gemfile, we cannot continue
ERROR: Unfortunately, a fatal error has occurred. Please see the Bundler
ERROR: troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
ERROR: /tmp/compile_unHgf/Gemfile:19:in `eval_gemfile': You need to configure config/database.yml first (RuntimeError)
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/dsl.rb:36:in `instance_eval'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/dsl.rb:36:in `eval_gemfile'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/dsl.rb:10:in `evaluate'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/definition.rb:26:in `build'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler.rb:153:in `definition'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli/platform.rb:10:in `block in run'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/ui/shell.rb:69:in `silence'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli/platform.rb:9:in `run'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli.rb:358:in `platform'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor/command.rb:27:in `run'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor.rb:363:in `dispatch'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor/base.rb:440:in `start'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli.rb:9:in `start'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/bin/bundle:20:in `block in <top (required)>'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/bin/bundle:20:in `<top (required)>'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/bin/bundle:19:in `load'
ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/bin/bundle:19:in `<main>'
!
ERROR: Build failed, exited 1
Since the problem has been caused by the gemfile here is mine,
source 'https://rubygems.org'
if ENV["HEROKU"]
ruby '2.1.3'
gem "pg"
gem "thin" # Change this to another web server if you want (ie. unicorn, passenger, puma...)
gem "rails_12factor"
else
require 'yaml'
env = ENV["RAILS_ENV"] || 'development'
dbfile = File.expand_path("../config/database.yml", __FILE__)
unless File.exists?(dbfile)
if ENV['DB']
FileUtils.cp "config/database.yml.#{ENV['DB'] || 'postgres'}", 'config/database.yml'
else
raise "You need to configure config/database.yml first"
end
end
conf = YAML.load(File.read(dbfile))
environment = conf[env]
adapter = environment['adapter'] if environment
raise "You need define an adapter in your database.yml or set your RAILS_ENV variable" if adapter == '' || adapter.nil?
case adapter
when 'sqlite3'
gem 'sqlite3'
when 'postgresql'
gem 'pg'
when 'mysql2'
gem 'mysql2'
else
raise "Don't know what gem to use for adapter #{adapter}"
end
end
gem 'rails', '~> 4.1.7'
gem 'htmlentities'
gem 'bluecloth', '~> 2.1'
gem 'coderay', '~> 1.1.0'
gem 'kaminari'
gem 'RedCloth', '~> 4.2.8'
gem 'addressable', '~> 2.1', :require => 'addressable/uri'
gem 'mini_magick', '~> 3.8.1', :require => 'mini_magick'
gem 'uuidtools', '~> 2.1.1'
gem 'flickraw-cached'
gem 'rubypants', '~> 0.2.0'
gem 'rake', '~> 10.3.2'
#gem 'acts_as_list'
#gem 'acts_as_tree_rails3'
gem 'fog'
gem 'recaptcha', :require => 'recaptcha/rails', :branch => 'rails3'
gem 'carrierwave', '~> 0.10.0'
gem 'akismet', '~> 1.0'
gem 'twitter', '~> 5.6.0'
gem "jquery-rails", "~> 3.1.0"
gem "jquery-ui-rails", "~> 5.0.2"
gem 'rails-timeago', '~> 2.0'
gem 'rails_autolink', '~> 1.1.0'
gem 'dynamic_form', '~> 1.1.4'
gem 'non-stupid-digest-assets'
# removed from Rails-core as Rails 4.0
gem 'actionpack-page_caching', '~> 1.0.2'
gem 'rails-observers', '~> 0.1.2'
group :assets do
gem 'sass-rails', " ~> 4.0.3"
gem 'coffee-rails', " ~> 4.0.1"
gem 'uglifier'
end
group :development, :test do
gem 'thin'
gem 'factory_girl', '~> 4.5.0'
gem 'capybara'
gem 'rspec-rails', '~> 3.1.0'
gem 'simplecov', :require => false
gem 'pry-rails'
gem 'better_errors', '~> 2.0.0'
gem 'binding_of_caller'
gem 'guard-rspec'
end
# Install gems from each theme
Dir.glob(File.join(File.dirname(__FILE__), 'themes', '**', "Gemfile")) do |gemfile|
eval(IO.read(gemfile), binding)
end

it looks like the part of the Gemfile that you want to use aka the if ENV["HEROKU"] block is not being executed. instead, the else block is invoked which raises the error in the snippet of the log you posted.
there are several possible causes of this that i'm going to write down in order of probablity
you did not set heroku config:set HEROKU=true as explained in the publify documentation
heroku ignores the environment variable
the custom build-pack you are using interferes with what you are trying to achieve
something else is broken

Related

There was an error while trying to load the gem 'ahoy_matey'

I'm not actually a ruby dev, I'm just trying to get development environment setup from a project and I'm having a world of trouble getting the gems in order so I can load up the server. I do mostly front-end work. Anyways, my error is:
There was an error while trying to load the gem 'ahoy_matey'.
Gem Load Error is: undefined method `hours' for 4:Fixnum
I've been searching google for last two days and can't come across anyone experiencing this issue with "ahoy_matey" gem. I get this error when trying to launch the server or rake migrations.
Ruby 1.9.3
Rails 3.2.13
mysql2 0.3.17
Any help is appreciated.
Full trace:
Bundler::GemRequireError: There was an error while trying to load the gem 'ahoy_matey'.
Gem Load Error is: undefined method `hours' for 4:Fixnum
Backtrace for gem load error is:
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy.rb:43:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy.rb:39:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy_matey.rb:1:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy_matey.rb:1:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:86:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `block in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler.rb:102:in `require'
/home/sirtastic/projects/dataraptor/config/application.rb:7:in `'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `require'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/bin/rake:33:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/rake:23:in `load'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/rake:23:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `eval'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `'
Bundler Error Backtrace:
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:90:in `rescue in block (2 levels) in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:85:in `block (2 levels) in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `block in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler.rb:102:in `require'
/home/sirtastic/projects/dataraptor/config/application.rb:7:in `'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `require'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `eval'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `'
(See full trace by running task with --trace)
source 'http://rubygems.org'
gem 'rails', '3.2.13'
gem 'mysql2'#, '~> 0.3.11'
gem 'sass-rails', '~> 3.2.3' # Because SCSS is compiled for embedded quoters
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'execjs', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails', '~> 3.0.4'
gem 'jquery-ui-rails', '~> 4.0.5'
gem 'jquery_datepicker'
group :production do
gem 'pry', require:false
end
group :development, :test do
gem 'capybara', :require => false
gem 'database_cleaner', :require => false # for use with capybara tests
gem 'factory_girl', '~> 4.1' # for generating test models
gem 'factory_girl_rails', require:false
gem 'forgery' # for generating test data
gem 'pry'
gem 'pry_debug'
gem 'pry-nav'
gem 'spork-rails', platform: [:mswin, :mingw] # Fast rpsec testing on Windows
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
end
group :development do
gem 'thin' # Sane development server
gem 'bullet' # for identifying areas to speed up database queries
gem 'meta_request' # for chrome rails-panel
gem 'rack-mini-profiler', require:false
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
end
group :test do
gem 'launchy', :require => false
gem 'rspec-rails'
gem "selenium-webdriver", "~> 2.40.0" # for AJAX testing
gem 'shoulda', :require => false
gem 'simplecov', :require => false # Test coverage
gem 'timecop'
gem 'vcr', '~> 2.9.3'#'~> 2.5.0'
gem "webmock", '~> 1.10.2'
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
end
group :dev, :release, :development do
gem 'better_errors'
gem 'binding_of_caller' # supports better errors by providing IDE in browser when error occurs
end
gem 'activeuuid', '>= 0.5.0'
gem 'ahoy_matey', '1.1.0' #needs this exact version in order to output UUIDs consistently. the next version after does not.
gem 'american_date' # by default, dates are parsed/formatted with American style
gem 'angularjs-rails', '~> 1.0.7'
gem 'attr_encrypted', '~> 1.2' # encrypt activerecord attributes in db
gem 'authlogic', '~> 3.2' # user login
gem 'aws-sdk'
gem 'capistrano', require: false# deployment of application
gem 'capistrano-ext', require: false
gem 'carrierwave' # file upload solution
gem 'daemons' # used for running delayed_job jobs
gem 'encryptor', '~> 1.1' # handle encryption of ActiveRecord fields
gem 'exception_notification', '~> 4.0.0'
gem 'faraday' # REST client for interfacing with external APIs
gem 'faraday_middleware'
gem 'fog', '~> 1.22' # for Amazon Web Services cloud storage
gem 'formatador', '~> 0.2' # This shouldn't need to be here. It is/was a dependency for fog-core, but it wasn't getting bundled (for some reason), so raking assets:precompile consistently failed. 2014-09-17.
gem 'haml', '~> 4.0.3'
gem 'holidays', '~> 2.1.0'
gem 'httpi', '~> 2.2.7'
gem 'json', '~> 1.8.1' # Specified so as to 'safely' conduct an update for the sake of stripe gem (2014-05-21)
gem 'liquid', '~> 2.5.0' # rendering templates, such as Marketing::Email::Template
gem 'mini_magick' # photo resizing
gem 'momentjs-rails'
gem 'multi_xml'
gem 'paperclip', '~> 3.5.0' # handle file attachments to activerecord
gem "paypal-recurring"
gem 'nested_form'
gem 'rails3-jquery-autocomplete'# supports autocomplete fields
gem 'redis' # for publishing
gem 'remotipart', '~> 1.0' # enables multipart form submissions over ajax
gem 'ruby-saml', '~> 1.0.0'
gem 'rvm-capistrano', require: false # for deploying to servers where multiple rubies are available
gem 'safe_attributes' # takes care of attribute name collisions w/ ActiveRecord (we use 'delay')
gem 'savon', '~> 2.7'
gem "select2-rails" # makes an autocomplete select box, compatible with x-editable
gem 'sidekiq', '~> 2.17.0' # handles background/delayed jobs
gem 'spreadsheet', require: false
gem "stripe", '~> 1.11.0'
gem 'tinymce-rails', '>= 4.0.8' # version 4.0.8 includes important bug fixes
gem 'transaction_retry' # Catch mysql deadlock and try again
gem 'tzip', '~> 0.0.4' # Find timezone by zip code
gem 'whenever', require: false # handles scheduled tasks
gem 'wicked_pdf' # creates pdfs from html (is a wrapper for wkhtmltopdf)
gem 'will_paginate', '~> 3.0' # paginates index pages for activerecord
gem 'wkhtmltopdf-binary' # the backend linux tool that creates pdfs from html using QT Webkit rendering engine
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
Looks like you might be requiring your bundle before requiring rails. If you have these two lines in your application.rb file, they need to be in this order:
require 'rails/all'
Bundler.require(:default, Rails.env)
So I see you're running just rails s. I know this question is old but maybe this might help someone else. So the command you want to be running is:
bundle exec rails s
bundle exec executes a command in the context of the bundle.
This command executes the command, making all gems specified in the Gemfile available to require in Rails.
Essentially, if you would normally have run something like rspec spec/my_spec.rb, and you want to use the gems specified in the Gemfile and installed via bundle install, you should run bundle exec rspec spec/my_spec.rb.
Note that bundle exec does not require that an executable is available on your shell's $PATH.
Source

heroku app/vendor/bundle shows wrong version of ruby

I'm am getting an error in production that doesn't occur in development. It appears in the stack trace that the gem is using the wrong version of ruby (2.1.0), but I have specified 2.1.3 in my gemfile and followed the heroku troubleshooting on ruby versions. Based on other stackoverflow information the ruby version makes a difference here. Anyone know how to update app/vendor/bundle to the latest?
This is my error which is occurring in a Resque worker...
undefined method `name' for nil:NilClass
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:72:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:150:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:150:in `accept'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:114:in `push'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych.rb:409:in `dump'
...snip...
This is my ruby version...
heroku run "ruby --version"
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
This is what's in /app/vendor/bundle...
heroku run "ls /app/vendor/bundle/ruby"
2.1.0
This is my Gemfile ruby declaration....
source 'https://rubygems.org'
group :default do
# current stable (heroku needs this listed)
ruby '2.1.3'
gem 'rails', '4.1.1'
gem 'redis' # queue mechanism
gem 'resque', "~> 1.22.0", :require => "resque/server"
gem 'resque_mailer' # mailer queue
gem 'resque-scheduler' # job scheduler
# postgres and database
gem 'pg' # postgres
gem 'activerecord-import' # bulk sql insert
gem 'seed-fu', '~> 2.3' # db seed data
# APIs
gem 'bitly'
gem 'feedjira' # RSS feeds
gem 'fullcontact'
gem 'httparty'# rest api client
gem 'twilio-ruby' # SMS
gem 'twitter'
gem 'twitter-text' # convert twitter, links, hashtags and users
gem 'yahoo-finance', require: 'yahoo_finance'
# WEB....
# Use unicorn as the app server
gem 'unicorn'
# javascript
gem 'jquery-rails'
gem 'uglifier', '>= 1.3.0' # compressor for js assets
gem 'coffee-rails', '~> 4.0.0'
# UI/CSS
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass'
gem 'jquery-ui-rails'
gem 'jqcloud-rails' # word cloud
gem 'footable-rails' # mobile responsive table
gem 'font-awesome-sass'# icons
gem 'highcharts-rails'
# rails
gem 'turbolinks'
gem 'simple_form'
# admin interface
gem 'rails_admin' # models admin interface
gem "psych", "~> 2.0.5" # needed for rails_admin
# user authentication
gem 'devise'
gem 'domp'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-stocktwits', :git => 'https://github.com/jesseyoungmann/omniauth-stocktwits.git'
# app support
gem 'bcrypt', '~> 3.1.2' # for active model secure password
gem 'kaminari', :git => 'https://github.com/musicglue/kaminari.git' # pagination
end
# docs
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# test
group :test do
gem "capybara"
gem 'factory_girl_rails'
gem 'faker'
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'simplecov', :require => false
gem 'vcr', '~> 2.8.0'
gem 'webmock', '~> 1.15.0'
end
# development
group :development do
gem 'foreigner', '~> 1.6.1' # foreign key generator
gem 'rails_layout'
# profilers
gem 'rack-mini-profiler'
gem 'ruby-prof'
end
group :production do
gem 'newrelic_rpm'
gem 'rails_12factor' # heroku
end
Thanks!
A possible solution is to create a .ruby-version file in the root of your application and simply put 2.1.3 in it, than your app will always use that version in production and development. I had similar issues in the past and this did the trick for me.
Duplicate of this:
Why Do Heroku Stack Traces indicate Ruby 1.9.1 is in use?
Same answer as this:
Why are we installing Ruby 1.9.2/1.9.3 gems into a 1.9.1 folder?

Rails & Heroku: PG db fails to create database

I have almost read every question and doc about deployment to heroku, and this is not my first time, but now in a very weird scnario when I deploy I can't create the database:
Running `rake db:create --trace` attached to terminal... up, run.8982
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
.
.
.
.
Couldn't create database for {"adapter"=>"postgresql", "host"=>"ec2-23-23-244-144.compute-1.amazonaws.com", "encoding"=>"unicode", "database"=>"d80e387p61nnl1", "pool"=>5, "template"=>"template0", "username"=>"******", "password"=>"********", "port"=>5432}
It's not this:
FactoryGirl screws up rake db:migrate process
I took out everything related to Factory girl pretty much, everything in the spec file.
Not this either:
Rails 4.0.1 on Heroku, can't create database
this is my gemfile:
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.1.2'
#Assets
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-turbolinks'
gem 'turbolinks'
gem "autoprefixer-rails"
#jQuery
gem 'magnific-popup-rails'
gem 'ckeditor'
gem 'gmaps4rails'
gem "select2-rails"
gem 'chosen-rails'
gem 'jquery-tokeninput-rails'
gem 'jquery-timepicker-rails'
gem 'easy_as_pie'
gem 'modernizr-rails'
gem "font-awesome-rails"
gem 'jquery-slimscroll-rails'
gem 'jquery-placeholder-rails'
gem 'autosize-rails'
gem 'newrelic_rpm'
#frontend
gem 'rails_12factor', group: :production
gem 'friendly_id', '~> 5.0.0' # Note: You MUST use 5.0.0 or greater for Rails 4.0+
gem 'rack-cors', :require => 'rack/cors'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'bootstrap-sass'
gem 'devise'
gem 'high_voltage'
gem 'thin'
gem 'lodash-rails'
#Database
gem 'ransack'
gem 'pg'
gem 'pg_search'
gem 'simple_form'
# gem 'ng-rails-csrf'
gem 'wiselinks'
# Development Only
group :development do
gem 'binding_of_caller', :platforms=>[:mri_19]
gem 'rails_layout'
gem 'meta_request'
gem 'better_errors'
gem 'hirb' #use Hirb.enable to enable it / text to Column
gem 'awesome_print', :require => 'ap'
gem 'railroady' #run this command: rake diagram:all
gem "bullet" # it always works unless you remove the initilzer
gem "reek" # run this : reek .
gem 'brakeman', :require => false # run this : brakeman [appPath] -o output_file
gem 'traceroute' # to check unUsed and Unreachable routes > rake traceroute
gem 'quiet_assets' #takes away the Asset messages in the Log
gem 'annotate', ">=2.6.0"
gem "letter_opener", :group => :development
gem 'rails_apps_pages'
end
group :development, :test do
gem 'rspec-rails'
end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem 'selenium-webdriver'
end
gem 'ffaker'
gem 'populator'
gem 'activeadmin', github: 'gregbell/active_admin'
# gem "meta_search", '>= 1.1.0.pre'
#rails Legacy Gems
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
#Images:
gem 'carrierwave'
gem 'rmagick', :require => false
gem 'kaminari'
# gem "bower-rails", "~> 0.8.3"
# gem 'react-rails', '~> 0.10.0.0'
# gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails'
# gem "therubyracer", :platforms => :ruby
# gem "therubyrhino", :platforms => :jruby
gem 'activerecord-reputation-system'
gem 'acts-as-taggable-on'
gem 'markable'
gem 'country_select', github: 'stefanpenner/country_select'
gem 'rails4-autocomplete'
# gem 'linkedin' hasie 3.3.0 error
#messaging
gem 'mailboxer'
IN my Heroku Logs, this what I found:
Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
2014-09-07T17:20:38.089695+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-07T17:20:38.089697+00:00 app[web.1]: Exiting
2014-09-07T17:20:38.357403+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:247:in `require': No such file to load -- mini_magick (LoadError)
2014-09-07T17:20:38.357406+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:247:in `block in require'
any help would be veryyy very much appreciated.
There are few lessons to be learnt from this problem that I came across, but first let's answer and then explain what was going on.
Short answer:
Despite removing the tests that was considered to cause the rake to break, there were other things left out that needed to be removed and it was causing problems:
1- In the application.rbthis was happening:
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: false,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
2- In seed.rb file this was happening:
# user = CreateAdminService.new.call
# puts 'CREATED ADMIN USER: ' << user.email
The lesson:
1- Don't use auto app generators. In my case I was using #RailsComposer.
2- Bower on Rails is a bad decision, it can turn a very simple app to a crazy amazin jungle

NoMethodError on Rails Server

I'm trying to start the Rails Server, but I get the following error and the server shuts down. I suspect I'm missing a dependency, but I'm a Ruby noob, so I very well could be wrong.
=> Booting WEBrick
=> Rails 4.1.0 application starting in development on `http://0.0.0.0:3000`
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/server.rb:133:in
`log_to_stdout': undefined method `formatter' for nil:NilClass
(NoMethodError) from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in
`start' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in
`block in server' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in
`tap' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in
`server' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in
`run_command!' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in
`<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in
`<main>'
UPDATED: I do not have "execjs" or "therubyracer" gems in my Gemfile. Here is what I have:
source 'https://rubygems.org'
ruby '2.1.1'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.1.0'
group :development do
gem 'sqlite3', '1.3.8'
end
gem 'sass', '3.3.6'
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
gem 'haml'
gem 'railties'
gem 'faraday', '~> 0.9.0'
gem 'annyang_rails'
gem 'savon', '~> 2.3.0'
gem 'httparty'
gem 'speechcloud', '~> 0.1.1'
gem 'json', '~> 1.8.1'
gem 'sinatra', '~> 1.4.5'
gem 'rack', '~> 1.4'
gem 'rack-protection', '~> 1.4'
gem 'permutation', '~> 0.1.8'
gem 'tilt', '~> 1.3'
gem 'bacon', '~> 1.2.0'
gem 'activesupport', '~> 4.1.0'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
As far as starting Rails server, I simply type Rails Server. Nothing else.
BTW, if you can't tell, I'm very new to RoR.
log_to_stdout': undefined method 'formatter' for nil:NilClass
(NoMethodError)
That's your error, and as pointed out in the comments, it looks like a problem with the logger
I can only surmise the issue will be with either a dependency (can you post your Gemfile please), or with your environment (not having ruby installed properly or something)
Can you post your Gemfile for us?
So, I finally came up with a solution. Thank you for putting me on the right track. I eventually tracked down the problem to my config.ru file. I changed it to:
require ::File.expand_path('../config/environment', __FILE__)
require './app'
run Sinatra::Application
This finally got the Rails Server up and running.

Rails 3.2 precompilation fails

I'm a newby in Rails, and I'm developing some app with 3.2.0. So, all is good, it works on my local environment, but when I try to push it to Heroku there are troubles with assets - my css files don't compile into one application.css file, therefore my final application.css is clean (you can see it by link my app on Heroku). There are no problems on my local machine. I've found some answers in Google and people recommended do the following command:
RAILS_ENV=production bundle exec rake assets:precompile
I tried to do it and got the following output:
/Users/marya/.rvm/rubies/ruby-1.9.3-p448/bin/ruby: No such file or directory -- ruby /Users/marya/.rvm/gems/ruby-1.9.3-p448#global/bin/rake assets:precompile (LoadError)
rake aborted!
Command failed with status (1): [/Users/marya/.rvm/rubies/ruby-1.9.3-p448/b...]
/Users/marya/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.0/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/Users/marya/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.0/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/marya/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.0/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/marya/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:14:in `eval'
/Users/marya/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:14:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
I don't understand what it does mean, therefore I need your help. My Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.0'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
end
group :production do
gem 'pg', '0.12.2'
gem 'rails_12factor'
end
# 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'
If you need another project files, please, just tell me about it and Ill do it. Thanks in advance!
Seems to be an RVM quirk. I ran into this using rvm + ruby 2.0.0-p247 and this worked for me:
rvm ruby-2.0.0-p247#global do gem install executable-hooks

Resources