Ruby-on-rails heroku open - 未指定应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12479668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:47:01  来源:igfitidea点击:

heroku open - no app specified

ruby-on-railsheroku

提问by Snowcrash

I've just created a simple Rails app using

我刚刚使用创建了一个简单的 Rails 应用程序

rails new myapp

then created the heroku stack using:

然后使用以下方法创建了 heroku 堆栈:

heroku create --stack cedar 

But when I try opening the app on Heroku using:

但是当我尝试使用以下命令在 Heroku 上打开应用程序时:

heroku open

I get:

我得到:

 !    No app specified.
 !    Run this command from an app folder or specify which app to use with --app <app name>

And this:

和这个:

$ heroku open --app myapp

gives me this:

给我这个:

 !    App not found

Am I missing something obvious?

我错过了一些明显的东西吗?

回答by Aaron Gray

If you have an existing app on Heroku and you are getting this no app specified message, you can correct it by running this on your local terminal:

如果您在 Heroku 上有一个现有的应用程序,并且您收到此未指定应用程序的消息,您可以通过在本地终端上运行来更正它:

heroku git:remote -a MyHerokuAppName

heroku git:remote -a MyHerokuAppName

回答by Marcin Olichwirowicz

Heroku by default is not creating app with your directory name, so when you do

默认情况下,Heroku 不会使用您的目录名称创建应用程序,因此当您这样做时

heroku create --stack cedar
Creating calm-bayou-3229... done, stack is cedar
http://calm-bayou-3229.herokuapp.com/ | [email protected]:calm-bayou-3229.git

it is creating application named 'calm-bayou-3229' And you can do

它正在创建名为“calm-bayou-3229”的应用程序,你可以做

heroku open --app calm-bayou-3229
Opening http://calm-bayou-3229.herokuapp.com/

You can always list your apps with:

您始终可以通过以下方式列出您的应用:

heroku apps

回答by David Vezzani

Another approach to solving the issue is to take a broad understanding of what the .git/config file associated with the heroku app is doing and make the necessary tweaks.

解决该问题的另一种方法是广泛了解与 heroku 应用程序关联的 .git/config 文件正在做什么并进行必要的调整。

1.Open .git/configfrom your heroku project's root.

1..git/config从你的heroku项目的根目录打开。

Your git config file may look something like this, especially if you are juggling a couple heroku accounts on your machine.

你的 git 配置文件可能看起来像这样,尤其是当你在你的机器上处理几个 heroku 帐户时。

git@heroku.{heroku.account}shows up instead of [email protected]because of the configuration in your ~/.ssh/configfile. The reference to heroku-app-8396.gitshould be updated to match your heroku project name. Each heroku account you have should have an entry in the ~/.ssh/configfile. Obviously, the heroku account that this heroku project is associated with should show up in your .git/configfile.

git@heroku.{heroku.account}显示而不是[email protected]因为~/.ssh/config文件中的配置。heroku-app-8396.git应更新对的引用以匹配您的 heroku 项目名称。您拥有的每个 heroku 帐户都应该在~/.ssh/config文件中包含一个条目。显然,与此 heroku 项目相关联的 heroku 帐户应显示在您的.git/config文件中。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:heroku-app-8396.git
[remote "heroku"]
    fetch = +refs/heads/*:refs/remotes/heroku/*
    url = [email protected]:heroku-app-8396.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[heroku]
  account = heroku.account

2.When I run git pull heroku master, all seems to run well.

2.当我跑步时git pull heroku master,一切似乎都运行良好。

3.When I run heroku logs, I get an error message:

3.当我运行时heroku logs,我收到一条错误消息:

$ heroku ps
!    No app specified.
!    Run this command from an app folder or specify which app to use with --app APP.

Why?

为什么?

As far as I can tell, the herokucommand doesn't seem to know what to do with the {heroku.account}references. If we change those references to com(which is the default value when you are not using the 'accounts' heroku plugin), the herokucommands work once again, but now our gitcalls are saying there is a different problem:

据我所知,该heroku命令似乎不知道如何处理这些{heroku.account}引用。如果我们将这些引用更改为com(当您不使用 'accounts' heroku 插件时,这是默认值),heroku命令将再次起作用,但现在我们的git调用表明存在不同的问题:

$ git pull heroku master

 !  Your key with fingerprint d6:1b:4c:48:8c:52:d4:d6:f8:32:aa:1a:e7:0e:a2:a1 is not authorized to access smooth-robot-8396.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

One way to resolve this is to define a remote for gitand a remote for herokuand then tell herokuwhich remote to use.

解决这个问题的一种方法是定义一个遥控器git和一个遥控器heroku,然后告诉heroku使用哪个遥控器。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:heroku-app-8396.git
[remote "heroku"]
    fetch = +refs/heads/*:refs/remotes/heroku/*
    url = [email protected]:heroku-app-8396.git
[remote "heroku-app"]
    fetch = +refs/heads/*:refs/remotes/heroku/*
    url = [email protected]:heroku-app-8396.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[heroku]
    remote = heroku-app
    account = heroku.account

I like to explicitly specify the remote when I'm pushing content to a remote, so the herokuremote is for that, even though this configuration also accommodates pushing/pulling using the default (e.g., git push). I create a new remote 'heroku-app' and add remote = heroku-appto tell herokuto use a remote that doesn't include the heroku account in the URI.

我喜欢在将内容推送到遥控器时明确指定遥控器,因此heroku遥控器就是为此而设的,即使此配置也支持使用默认值(例如,git push)的推/拉。我创建了一个新的远程“heroku-app”并添加remote = heroku-app以告诉heroku使用一个在 URI 中不包含 heroku 帐户的远程。

Now I can run my gitand herokucommands as I want to.

现在我可以根据需要运行我的githeroku命令。

回答by Richardlonesteen

I had the same issue, All I had to do was cd to project dir instead of running commands from model folder in the project dir.

我遇到了同样的问题,我所要做的就是 cd 到项目目录,而不是从项目目录中的模型文件夹运行命令。

回答by xameeramir

This crazy thing worked for me:

这件疯狂的事情对我有用:

If you have the app's git repo copy on you local machine then cdto that location and that's it!!

如果您在本地机器上有应用程序的 git repo 副本,然后cd到该位置,就是这样

You will be able to use the app. You can verify this by commands like: heroku logs -n 1500

您将能够使用该应用程序。您可以通过以下命令验证这一点:heroku logs -n 1500