【问题标题】:Why do I sometimes have to specify what app I'm targeting in heroku?为什么有时我必须在 heroku 中指定我要定位的应用程序?
【发布时间】:2020-10-30 00:07:37
【问题描述】:

我有两个不同的应用程序部署到 heroku。在其中一个中,要访问生产控制台,我必须输入:

heroku run rails console

但是,在另一种情况下,当我没有使用 -a foo / --a=foo 指定应用程序时,CLI 会向我咆哮。我最终输入了这个:

heroku run rails console -a seaweed-soup

使用--help 运行命令会显示一些不一致的建议:

➜  seaweed-soup (master) ✔ heroku run rails console --help
run a one-off process inside a heroku dyno

USAGE
  $ heroku run

OPTIONS
  -a, --app=app        (required) parent app used by review apps
  -e, --env=env        environment variables to set (use ';' to split multiple vars)
...

应用程序标志并不是真正需要的,因为我可以在没有它的情况下在其他存储库中运行该命令。因此,据推测,在某些时候,我已将其中一个存储库配置为将 app 的值设置为有用的地方。但是,我在the docs 中没有发现任何东西,而env 也没有显示出任何有希望的东西。

我唯一的另一个想法是.git/config 文件看起来略有不同,但我不可能手动修改它们,所以我假设有一些经过批准的配置方式。有没有人遇到过这种情况?

【问题讨论】:

  • git remote -v 显示什么?我认为 Heroku 使用遥控器来确定您要与哪个应用程序交互。
  • 啊哈 - 在配置有用的应用程序中,git remote -v 显示了一个 heroku 存储库,而海藻汤没有。这为我指明了正确的方向,谢谢!

标签: heroku heroku-cli


【解决方案1】:

正如上面评论中所指出的,我的 git 远程存储库配置不同。我做了一些搜索,找到了useful documentation。通过运行:

heroku git:remote -a seaweed-soup

我的 git 配置过去是这样的:

...
[heroku]
    remote = seaweed-soup

运行上面的命令使它看起来像这样:

...
[heroku]
    remote = seaweed-soup
[remote "seaweed-soup"]
    url = https://git.heroku.com/seaweed-soup.git
    fetch = +refs/heads/*:refs/remotes/seaweed-soup/*

所以我手动删除了过时的(格式错误的?)条目,假设格式已经悄悄改变或者我很久以前配置错误。

【讨论】:

    猜你喜欢
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多