我在/config/initializers/carrier_wave.rb中添加了aws访问信息:
if Rails.env.production?
CarrierWave.configure do |config|
config.fog_credentials = {
# Configuration for Amazon S3
:provider => 'AWS',
:aws_access_key_id => ENV['access_key'],
:aws_secret_access_key => ENV['secret_access_key'],
}
config.fog_directory = ENV['bucket']
end
end
但是当我尝试推送到heroku时,我收到以下错误:我不知道还能做什么,任何帮助将不胜感激。
JUSTINs-iMac:premidx justindoshay$ git push heroku
Fetching repository, done.
Counting objects: 23, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 1.09 KiB | 0 bytes/s, done.
Total 12 (delta 9), reused 0 (delta 0)
-----> Removing .DS_Store files
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.1.3
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Using rake 10.3.2
Using minitest 5.4.2
Using thread_safe 0.3.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.1
Using rack 1.6.0.beta
Using i18n 0.7.0.beta1
Using mime-types 2.4.3
Using arel 6.0.0.beta2
Using bcrypt 3.1.7
Using sass 3.4.7
Using json 1.8.1
Using will_paginate 3.0.7
Using thor 0.19.1
Using cancan 1.6.10
Using uber 0.0.10
Using execjs 2.2.2
Using formatador 0.2.5
Using coffee-script-source 1.8.0
Using excon 0.41.0
Using net-ssh 2.9.1
Using inflecto 0.0.2
Using multi_json 1.10.1
Using ipaddress 0.8.0
Using gritter 1.1.0
Using hike 1.2.3
Using kgio 2.9.2
Using pg 0.17.1
Using bundler 1.6.3
Using subexec 0.2.3
Using rails_serve_static_assets 0.0.2
Using tilt 1.4.1
Using raindrops 0.13.0
Using rails_stdout_logging 0.0.3
Using tzinfo 1.2.2
Using nokogiri 1.6.4
Using rack-test 0.6.2
Using rdoc 4.1.2
Using mail 2.6.3
Using bootstrap-will_paginate 0.0.10
Using bootstrap-sass 3.2.0.0
Using uglifier 2.5.3
Using faker 1.4.2
Using coffee-script 2.3.0
Using net-scp 1.2.1
Using fog-json 1.0.0
Using mini_magick 3.8.0
Using unicorn 4.8.3
Using activesupport 4.2.0.beta4
Using sprockets 2.12.3
Using rails_12factor 0.0.2
Using sdoc 0.4.0
Using fog-core 1.24.0
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.0
Using loofah 2.0.1
Using jbuilder 2.2.3
Using activemodel 4.2.0.beta4
Using fog-brightbox 0.6.1
Using fog-softlayer 0.3.23
Using rails-dom-testing 1.0.4
Using activejob 4.2.0.beta4
Using rails-html-sanitizer 1.0.1
Using activerecord 4.2.0.beta4
Using carrierwave 0.10.0
Using actionview 4.2.0.beta4
Using fog 1.23.0
Using friendly_id 5.0.4
Using actionpack 4.2.0.beta4
Using actionmailer 4.2.0.beta4
Using sprockets-rails 3.0.0.beta1
Using simple_form 3.0.2
Using railties 4.2.0.beta4
Using coffee-rails 4.0.1
Using cells 3.11.2
Using jquery-rails 4.0.0.beta2
Using rails 4.2.0.beta4
Using sass-rails 5.0.0.beta1
Using turbolinks 2.3.0
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (0.79s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:237:in `validate_options'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:261:in `handle_settings'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:98:in `new'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/storage.rb:26:in `new'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:83:in `eager_load_fog'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:96:in `fog_credentials='
/tmp/build_147081514681b2a6351adf453926ef97/config/initializers/carrier_wave.rb:3:in `block in <top (required)>'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:118:in `configure'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave.rb:14:in `configure'
/tmp/build_147081514681b2a6351adf453926ef97/config/initializers/carrier_wave.rb:2:in `<top (required)>'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:246:in `load'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:246:in `block in load'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:237:in `load_dependency'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:246:in `load'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/engine.rb:648:in `block in load_config_initializer'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/notifications.rb:166:in `instrument'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/engine.rb:647:in `load_config_initializer'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/engine.rb:611:in `each'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/engine.rb:611:in `block in <class:Engine>'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/initializable.rb:30:in `run'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/initializable.rb:44:in `each'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/initializable.rb:44:in `tsort_each_child'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/application.rb:349:in `initialize!'
/tmp/build_147081514681b2a6351adf453926ef97/config/environment.rb:5:in `<top (required)>'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:252:in `require'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:252:in `block in require'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:237:in `load_dependency'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:252:in `require'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/application.rb:325:in `require_environment!'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta4/lib/rails/application.rb:438:in `block in run_tasks_blocks'
/tmp/build_147081514681b2a6351adf453926ef97/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-3.0.0.beta1/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app
To git@heroku.com:damp-coast-2948.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:damp-coast-2948.git'
答案 0 :(得分:1)
确保您的环境变量已设置
您可以通过运行
来完成此操作heroku config
在您的终端。
如果您没有看到ACCESS_KEY
或,则此命令将输出您当前的环境变量
SECRET_ACCESS_KEY
然后在终端
heroku config:set ACCESS_KEY=YOUR_ACCESS_KEY_HERE
heroku config:set SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY_HERE
答案 1 :(得分:0)
您必须设置配置变量。转到Heroku上的应用程序,单击“设置”和“显示配置变量”。