Need help.
When I try to make
user#X220:~/rails_projects/sample_app$ heroku run rake db:migrate
There is a mistake:
Running rake db:migrate on limitless-fjord-69900.... up, run.2816
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded.
Add gem 'pg' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:177:in rescue in spec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:174:inspec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:50:in establish_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:inblock (2 levels) in '
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in instance_eval'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:inexecute_hook'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:ineach'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:26:in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/mysql_database_tasks.rb:8:in'
.
.
.
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
My Gemfile is:
'source 'https://rubygems.org'
ruby '2.2.0'
gem 'activerecord', '~> 4.2', '>= 4.2.6'
gem 'rails', '4.2.6'
group :development, :test do
gem 'byebug'
gem 'sqlite3', '~> 1.3', '>= 1.3.11'
gem 'rspec-rails', '~> 2.8'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
group :doc do
gem 'sdoc', '~> 0.4.0', require: false
end
gem 'unicorn'
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
What's wrong?
Remove or comment gem 'sqlite3' from your Gemfile even if it in development group.
I don't know why but Heroku doesn't run your application when it contains sqlite gem outside production.
If you are use SQLite in development, you have to comment gem 'sqlite' every time when deploying to Heroku and uncomment after deploying.Better way will be use Postgres in development.
As suggested before, this could have to do with your sqlite gem.
If you still want to use sqlite you can set to ignore that group. From Heroku docs:
To specify groups of gems to not to be installed, you can use the BUNDLE_WITHOUT config var.
$ heroku config:set BUNDLE_WITHOUT="development:test"
Related
After I installed gem grape-jbuilder
and run bundle exec rails s it showed this message
bin/rails:6: warning: already initialized constant APP_PATH
/Users/xxx/xxx/bin/rails:6: warning: previous definition of APP_PATH was
here
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
And when I run bundle exec rake rails:update:bin
It show the error message below
rake aborted!
LoadError: cannot load such file -- hashie/hash
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in require'
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:inblock in require'
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in load_dependency'
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:inrequire'
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/grape-jbuilder-0.2.0/lib/grape/jbuilder.rb:2:in <top (required)>'
/Users/xxx/xxx/config/application.rb:7:in'
/Users/xxx/xxx/Rakefile:4:in require'
/Users/xxx/xxx/Rakefile:4:in'
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in <top (required)>'
/Users/xxx/.rbenv/versions/2.3.1/bin/bundle:23:inload'
/Users/xxx/.rbenv/versions/2.3.1/bin/bundle:23:in <main>'
LoadError: cannot load such file -- grape-jbuilder
/Users/xxx/xxx/config/application.rb:7:in'
/Users/xxx/xxx/Rakefile:4:in require'
/Users/xxx/xxx/Rakefile:4:in'
/Users/xxx/xxx/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in <top (required)>'
/Users/xxx/.rbenv/versions/2.3.1/bin/bundle:23:inload'
/Users/jiaping/.rbenv/versions/2.3.1/bin/bundle:23:in `'
(See full trace by running task with --trace)
Gemfile
gem 'rails', '4.2.4'
gem 'rack-contrib'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'therubyracer'
gem 'rb-readline'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'bootstrap-sass'
gem 'font-awesome-rails'
gem 'react-rails'
gem 'coffee-rails', '~> 4.1.0'
gem 'uglifier', '>= 1.3.0'
gem 'sass-rails'
gem 'momentjs-rails'
gem 'bootstrap3-datetimepicker-rails'
gem 'jquery-payment-rails', git: 'https://github.com/thoughtbot/jquery-payment-rails.git'
gem 'page_title_helper'
gem 'sprockets-es6', require: 'sprockets/es6'
gem 'jbuilder', '~> 2.0'
gem 'sorcery'
gem 'oauth2', '~> 1.3.0'
gem 'bcrypt'
gem 'dotenv-rails'
gem 'config', '~> 1.0.0'
gem 'enum_help'
gem 'mysql2', '~> 0.3.18'
gem 'squeel'
gem 'seed-fu'
gem 'carrierwave'
gem 'carrierwave-data-uri'
gem 'carrierwave-aws'
gem 'rmagick'
gem 'acts_as_list'
gem 'kaminari'
gem 'ransack'
gem 'rails-jquery-autocomplete'
gem 'gretel'
gem 'email_validator'
gem 'icalendar'
gem 'bootstrap_form'
gem 'paranoia', '~> 2.0'
gem 'unicorn'
gem 'unicorn-rails'
gem 'unicorn-worker-killer'
gem 'google-analytics-rails'
gem 'meta-tags'
gem 'web-console', '~> 2.0', group: :development
gem 'adminlte2-rails'
gem 'geocoder'
gem 'validates_timeliness', '~> 4.0'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'whenever', require: false
gem 'holiday_jp'
gem 'exception_notification', github: 'smartinez87/exception_notification'
gem 'slack-notifier'
gem 'grape'
gem 'grape-jbuilder'
group :staging do
gem 'letter_opener_web'
end
group :development, :test do
gem 'letter_opener'
gem 'spring'
gem 'spring-commands-rspec'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'simplecov', require: false
gem 'rubocop'
gem 'byebug'
gem 'better_errors'
gem 'pry'
gem 'pry-byebug'
gem 'pry-doc'
gem 'pry-rails'
gem 'pry-stack_explorer'
gem 'quiet_assets'
gem 'awesome_print'
gem 'annotate'
gem 'migration_comments'
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rails'
gem 'capistrano-rbenv'
gem 'capistrano-bundler'
gem 'capistrano3-unicorn'
gem 'rails-admin-scaffold'
end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'faker'
gem 'fuubar'
gem 'launchy'
gem 'selenium-webdriver'
gem 'shoulda-matchers'
gem 'timecop'
end
How can I solve this problem?
From here:
Actually it's spring which cause this issue. Try to comment it in the
Gemfile, then bundle install and restart the server ; shutting it
down, the warning is not present anymore.
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
I was getting an error with my application, so I looked on stack and found an answer undefined method `require_relative' for main:Object (NoMethodError) it said that I should run gem install rails which I did, after I ran that, when I tried to run rails generate controller StaticPages home help --no-test-framework
I got an error:
(in /usr/local/rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/usr/local/rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
It says that I am running rails .95 and even when I ran gem update rails nothing happend
Here is my gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.2'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
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'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Try deleting your Gemfile.lock (or perhaps moving it). This worked for me.
I am going through the railstutorial.org book.
I am receiving this error:
$ bundle exec guard init rspec
c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/interactor.rb:1:in
require': cannot load such file -- pry (LoadError)
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/inter
actor.rb:1:in'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/dsl.r
b:2:in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/dsl.r
b:2:in'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard.rb:6:
in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard.rb:6:
in'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/bin/guard:3:in
require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/bin/guard:3:in
'
from c:/Ruby200-x64/bin/guard:23:in load'
from c:/Ruby200-x64/bin/guard:23:in'
My gem file is:
1. source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.0.0'
gem 'guard', '2.0.3'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'rb-notifu', '0.0.4'
gem 'win32console', '1.3.2'
gem 'wdm', '0.1.0'
end
# Use SCSS for stylesheets
gem 'sass-rails', '4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'
# 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', '1.1.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Am I missing something? Thanks for any help!
Looks like guard requires pry be installed.
gem install pry
Explicitly add pry or similar to your Gemfile. I use pry-nav which will automatically bundle pry when bundle install is run.
# Gemfile
gem 'pry-nav', group: [:development, :test]
Cite:
http://pryrepl.org/
https://github.com/nixme/pry-nav
https://github.com/nixme/pry-debugger
https://github.com/rweng/pry-rails
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