繁体   English   中英

厨师食谱的资产预编译问题

[英]assets precompiling issues with chef recipe

我在通过厨师食谱预编译资产时遇到问题。

我的配方块包含

execute "rake assets:precompile" do   
cwd current_release_directory    
command "bundle exec rake assets:precompile  --trace"    
environment "RAILS_ENV" => "production"    
end

和database.yml文件包含,

production:    
  adapter: mysql2    
  encoding: utf8    
  reconnect: true    
  database: <%= ENV['production_db'] %>     
  pool: 25     
  username: <%= ENV['production_username'] %>    
  password: <%= ENV['production_password'] %>    
  socket: /var/run/mysqld/mysqld.sock    
  host: <%= ENV['production_host'] %>       

当我运行食谱时,出现以下错误。

  Compiled Resource:    
  ------------------    
  # Declared in /var/chef/cache/cookbooks/env_setup/recipes/default.rb:255:in `from_file'     

  execute("rake assets:precompile") do     
    action "run"    
    retries 0     
    retry_delay 2    
    guard_interpreter :default     
    command "bundle exec rake assets:precompile  --trace"    
    backup 5    
    cwd "/home/ubuntu/apps/new_spree_st/current"    
    environment {"RAILS_ENV"=>"production"}    
    returns 0    
    cookbook_name "env_setup"    
    recipe_name "default"    
  end    


Running handlers:    
[2014-12-03T18:38:04+05:30] ERROR: Running exception handlers    
Running handlers complete    
[2014-12-03T18:38:04+05:30] ERROR: Exception handlers complete    
[2014-12-03T18:38:04+05:30] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out    
Chef Client failed. 16 resources updated in 139.571723545 seconds    
[2014-12-03T18:38:04+05:30] ERROR: execute[rake assets:precompile] (env_setup::default line     255) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'    
---- Begin output of bundle exec rake assets:precompile  --trace ----    
STDOUT: Your Gemfile lists the gem hiredis (~> 0.4.5) more than once.    
You should probably keep only one of them.    
While it's not a problem now, it could cause errors if you change the version of just one of them later.    
STDERR: ** Invoke assets:precompile (first_time)    
** Execute assets:precompile    
/opt/chef/embedded/bin/ruby /usr/local/rvm/gems/ruby-2.0.0-p481/bundle/ruby/1.9.1/bin/rake   assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace    
** Invoke assets:precompile:all (first_time)    
** Invoke assets:cache:clean (first_time)    
** Invoke assets:environment (first_time)    
** Execute assets:environment    
** Invoke environment (first_time)    
** Execute environment    
rake aborted!    
Psych::SyntaxError: (<unknown>): could not find expected ':' while scanning a simple key at line 11 column 3    

可能是什么问题?

您必须将环境production_usernameproduction_passwordproduction_host添加到环境中,因为在运行bundle exec rake命令时,database.yml会填充环境中的值。

基本上,您收到该错误,因为您的database.yml对于该值是空的。

一个简单的解决方法是将后备添加到您的database.yml

<%= ENV['production_db'] || '""' %>  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM