【发布时间】:2014-11-10 22:32:52
【问题描述】:
我有一个可以使用 env=prod 在本地运行并且可以部署的应用程序,但我无法在 heroku 上运行任何 rake 命令。
我的服务器在 ENV=production 中本地运行。在我创建数据库之前,它以与 heroku 完全相同的方式失败,然后在我执行 db:setup 之后工作正常。问题肯定是我在heroku上创建数据库的命令失败了。
如果我运行“heroku run echo”hello”,我会得到输出“hello”。我在 Heroku 上运行命令的一般能力不是问题。
但是,如果我运行“heroku run rake [ANY_COMMAND]”,我将没有任何输出并且会出现静默失败。
如果我执行 heroku 运行 bash 然后 rake db:migrate 而不指定环境,它运行良好
-
如果我执行 heroku 运行 bash 然后 rake db:migrate ENV="production" 我得到
ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
然后没有别的了。回到一个活跃的 bash 提示符。没有错误
-
如果我执行 heroku 运行 bash 然后 rake db:setup RAILS_ENV="production" 我得到:
FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege.无法为 {"adapter"=>"postgresql", "username"=>"dangfjubjcfyxp", "password"=>随机字符串[已编辑], "port"=>5432, "database 创建数据库"=>[已编辑]}
不确定这是否只是因为您不应该在 heroku 上运行该命令,或者这实际上是一个问题。
-
1234563不确定这是否可以预期。
-
把我的 heroku 应用程序搞砸了,从头开始,得到了相同的结果
#ROOT/bin/rake #!/usr/bin/env ruby begin load File.expand_path("../spring", __FILE__) rescue LoadError end require_relative '../config/boot' require 'rake' Rake.application.run
这让我觉得我的一个关于 rake 的 bin 目录配置可能搞砸了。也许是对“PATH”的引用?
其他一些可能的相关文件:
#ROOT/Procfile
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
#ROOT/config/production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
如果发布其他文件对我有帮助,请告诉我
我有另一个类似的问题here,它显示了我的更多文件,但我认为我的理解已经发生了很大变化,可以完全重新构建问题,所以我认为新帖子会更好。
【问题讨论】:
标签: ruby-on-rails ruby heroku rake