我试图在rails项目上的现有ruby上进行设置,但是我在postgres数据库设置上挂了。我用RVM用ruby 2.1.2设置项目。使用以下命令使用自制软件安装pg gem:
gem install pg -- --with-pg_config=/usr/local/bin/pg_config
我的database.yml文件如下所示:
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:
我捆绑了我所有的宝石。
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'
我使用以下方法手动启动了postgres服务器:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
日志文件输出:
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'
或者我使用postgresapp启动服务器。
当我运行rake db:setup时,我得到了这个:
myapp_development already exists
myapp_test already exists
它会创建一堆表和索引,然后当它到达此处时停止:
-- 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)
宝石文件中的某个宝石可能有问题吗?
这个问题很类似:Carrierwave, Rails 4; Errno::ENOENT (No such file or directory - identify)。也许某些宝石是错误的版本?
答案 0 :(得分:1)
要解决此问题,请从此处安装ImageMagick CLI工具:imagemagick.org/script/binary-releases.php,Mac OS二进制版。使用MacPorts进行安装,这会将路径添加到我的.bash_profile文件中。现在rake db:setup命令能够找到ImageMagick,并且可以工作。