Im trying to get setup on an existing ruby on rails project, but am getting hung up on the postgres db setup. I used RVM to set up the project with ruby 2.1.2. Installed the pg gem with homebrew using the following command:
gem install pg -- --with-pg_config=/usr/local/bin/pg_config
My database.yml file looks like this:
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myusername
password:
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myusername
password:
I bundle installed all my gems.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
gem 'activerecord-session_store'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# 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'
gem 'jquery-ui-rails'
# authentication using Devise (email / password) and omniauth (oauth)
gem "devise", '~> 3.2.0'
gem 'devise_invitable', '~> 1.3.0'
gem "beta_invites", :github=>'danman01/beta_invites'
gem 'jquery-datatables-rails', git: 'git://github.com/rweng/jquery-datatables-rails.git'
gem "omniauth-soundcloud"
# validation for emails
gem 'valid_email'
# set env variables within config/application.yml
gem "figaro"
# 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', '~> 1.2'
# User roles. ex: User.first.add_role!("admin")
gem "easy_roles"
# manage meta tags
gem "meta-tags", :require => "meta_tags"
# error notification. TODO - setup https://github.com/smartinez87/exception_notification
gem 'exception_notification', git: "git://github.com/smartinez87/exception_notification.git"
# nice rails urls for seo and readability
gem "friendly_id", '~> 5.0.0'
# use foreman start to startup multiple processes at once (i.e. rails and delayed job queue)
gem "foreman"
gem "nokogiri", '~> 1.6.3'
# pagination
gem "kaminari"
# admin panel, available at /admin
gem "rails_admin"
# cron scheduling for the server. See config/schedule
gem 'whenever', :require =>false
# tool to party
gem 'httparty'
gem 'simple_form'
gem 'bootstrap-sass', '~> 3.1.1'
# app permissions. set in models/ability.rb
gem 'cancancan', '~> 1.8'
# caching
gem 'dalli'
# activity feed
gem 'public_activity'
# image upload
gem 'carrierwave'
gem 'carrierwave-aws'
gem 'mini_magick'
gem "sidekiq"
gem 'sinatra', require: false
gem 'slim'
# tree structure
gem "ancestry"
# more organized db seeds
gem "seedbank"
# run code safely in migrations
gem 'migration_data'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :development do
# better formatting of errors
gem "better_errors"
# do not output so much about assets to console
gem "quiet_assets"
# debugging tool: https://github.com/banister/binding_of_caller
gem "binding_of_caller"
gem "tracer_bullets"
end
group :development, :test do
gem 'rspec-rails'
gem "faker"
gem "factory_girl_rails", "~> 4.0"
gem "pry-rails"
gem 'pry-byebug'
# preload rails app to speed things up
gem "spring"
gem "spring-commands-rspec"
# auto run things
gem "guard"
gem "guard-rspec", require: false
gem 'rb-fsevent' if `uname` =~ /Darwin/
gem 'thin' # or thin
end
group :development, :production do
gem 'cohort_me'
end
group :test do
gem 'capybara'
gem "launchy"
gem "database_cleaner"
end
# Rails view utilities
# use country-select with priority countries like: country_select("user", "country_name", [ "United Kingdom", "France", "Germany" ])
gem 'country-select'
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
gem 'unicorn'
# random comment
# Use Capistrano for deployment
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano', '~>3.1'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rvm'
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'#
# gem 'rails_12factor', group: :production
# ruby '2.1.1'
gem 'rb-fsevent'
I started the postgres server manually using:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
The logfile outputs this:
ERROR: database "myapp_development" already exists
STATEMENT: CREATE DATABASE "musictown_development" ENCODING = 'unicode'
ERROR: database "myapp_test" already exists
STATEMENT: CREATE DATABASE "musictown_test" ENCODING = 'unicode'
Alternatively i used the postgresapp to start the server.
And when I run rake db:setup I get this:
myapp_development already exists
myapp_test already exists
It creates a bunch of tables and indexes then when it gets here it stops:
-- initialize_schema_migrations_table()
-> 0.0154s
rake aborted!
Errno::ENOENT: No such file or directory - identify
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/subexec-0.2.3/lib/subexec.rb:71:in `spawn'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/subexec-0.2.3/lib/subexec.rb:71:in `spawn'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/subexec-0.2.3/lib/subexec.rb:55:in `run!'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/subexec-0.2.3/lib/subexec.rb:41:in `run'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:405:in `run'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:399:in `run_command'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:184:in `valid?'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:140:in `create'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:47:in `read'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:111:in `block in open'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:110:in `open'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/mini_magick-3.8.0/lib/mini_magick/image.rb:110:in `open'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/processing/mini_magick.rb:260:in `manipulate!'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/processing/mini_magick.rb:153:in `resize_to_fit'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/processing.rb:84:in `block in process!'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/processing.rb:76:in `each'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/processing.rb:76:in `process!'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:18:in `each'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:18:in `with_callbacks'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/uploader/cache.rb:122:in `cache!'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:329:in `cache'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:163:in `image='
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:39:in `image='
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/attribute_assignment.rb:42:in `public_send'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/attribute_assignment.rb:42:in `_assign_attribute'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/attribute_assignment.rb:29:in `block in assign_attributes'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/attribute_assignment.rb:23:in `each'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/attribute_assignment.rb:23:in `assign_attributes'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/core.rb:460:in `init_attributes'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/core.rb:185:in `initialize'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/inheritance.rb:27:in `new'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/inheritance.rb:27:in `new'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/persistence.rb:36:in `create'
/Users/myusername/Documents/MusicTown/musictown/db/seeds.rb:9:in `block in define_seed_task'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/seedbank-0.3.0/lib/seedbank/dsl.rb:24:in `module_eval'
/Users/myusername/.rvm/gems/ruby-2.1.2/gems/seedbank-0.3.0/lib/seedbank/dsl.rb:24:in `block in define_seed_task'
/Users/myusername/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/Users/myusername/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:setup => db:seed => db:seed:common => db:seed:original
(See full trace by running task with --trace)
Maybe theres something wrong with one of the gems in the gemfile?
This question is sorta similar: Carrierwave, Rails 4; Errno::ENOENT (No such file or directory - identify). Maybe some gem is the wrong version?
To fix this, install ImageMagick CLI tools from here: imagemagick.org/script/binary-releases.php, Mac OS Binary Release. Installing with MacPorts, which adds the paths to my .bash_profile file. Now rake db:setup command is able to find ImageMagick, and works.