为什么有时我必须指定我在heroku中定位的应用程序?

问题描述

我将两个不同的应用程序部署到了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远程存储库配置不同。我进行了搜索,发现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/*

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