简体   繁体   English

推送应用程序到heroku

[英]push rails app to heroku

I am trying to push a rails application to heroku. 我正在尝试将rails应用程序推送到heroku。

When I get to the last step: 当我到达最后一步时:

git push heroku master

It doesn't work and gives me these errors: 它不起作用,并给我这些错误:

Counting objects: 85, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (74/74), done.
Writing objects: 100% (85/85), 24.38 KiB, done.
Total 85 (delta 23), reused 0 (delta 0)

-----> Heroku receiving push
 !     Heroku push rejected, no Rails or Rack app detected.

error: hooks/pre-receive exited with error code 1
To git@heroku.com:smooth-dusk-26.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:smooth-dusk-26.git'

I don't know what I'm doing wrong :( 我不知道我做错了什么:(

Here's the answer I got from Heroku and it worked for me (after trying different pg gems, adapters, and everything else on the 10 other posts about this) 这是我从Heroku得到的答案,它对我有用(在尝试了不同的pg宝石,适配器以及其他10篇关于此的其他帖子之后)

1) add the line: gem 'pg' to your Gemfile. 1)将行:gem'pg'添加到您的Gemfile中。

2) Run the command bundle install to install the gem into your bundle. 2)运行命令bundle install install将gem安装到您的bundle中。

3) Stage the Gemfile and Gemfile.lock changes: git add Gemfile Gemfile.lock 3)暂存Gemfile和Gemfile.lock更改:git add Gemfile Gemfile.lock

4) Commit the changes: git commit -m "Install the pg gem" 4)提交更改:git commit -m“安装pg gem”

5) Redeploy to heroku: git push heroku master 5)重新部署到heroku:git push heroku master

When you created your Rails application, did you change directory into the directory of the application? 在创建Rails应用程序时,是否将目录更改为应用程序的目录? You have to perform all the commands from within the application's directory. 您必须从应用程序的目录中执行所有命令。

rails myapp
cd myapp

I encountered the same errors working through Chapter 1 of Michael Hartl's Rails Tutorial . 我在Michael Hartl的Rails教程的第1章中遇到了同样的错误。 They were eventually resolved by issuing another git commit command after opening a Heroku account and configuring the SSH keys: git commit -a -m "Heroku recommit" 在打开Heroku帐户并配置SSH密钥后,最终通过发出另一个git commit命令来解决它们: git commit -a -m“Heroku重新发送”

git push heroku master then succeeded. git push heroku master然后成功了。

For me it was the presence of index.php that fixed it. 对我来说,修复它的是index.php的存在。 Heroku seems to check for existence of index.php on pre-commit. Heroku似乎检查了pre-commit上是否存在index.php。

I just had the same problem trying to push my app to heroku and none of the above answers fixed it. 我只是遇到了同样的问题,试图将我的应用程序推送到heroku,并没有上述答案修复它。

I solved the issue by emptying my RVM Gemset with rvm gemset empty , deleting my Gemfile.lock (probably best to just rename it) and reinstalling my gems. 我通过将rvm gemset empty清空我的RVM rvm gemset empty ,删除我的Gemfile.lock(可能最好只重命名)并重新安装我的宝石来解决这个问题。 Pushing worked fine after this. 在此之后推动工作正常。

Got the same problem under windows following one of the guides on ror site. 在ror网站上的一个指南之后的Windows下遇到了同样的问题。 After making everything like here http://devcenter.heroku.com/articles/quickstart it was solved. 在制作了像http://devcenter.heroku.com/articles/quickstart这样的所有内容后,它就解决了。

Seems like problem was because of missing two lines. 似乎问题是因为缺少两行。

cd myapp cd myapp

git init git init

此外,如果您使用的是Rails 3.0,请确保使用雪松堆栈

heroku create --stack cedar

I went through the Rails Tutorial and didn't have a single problem with Heroku (MAC OS X), but you do have to follow the directions. 我浏览了Rails教程并没有Heroku(MAC OS X)的单一问题,但你必须遵循指示。

First, make sure you add/commit to Git. 首先,确保添加/提交给Git。 Then if you're in a -b (branch) you need to checkout into master, then merge the branch. 然后,如果你在-b(分支)中,你需要签出到master,然后合并分支。 If you've made changes to assets, you need to rake asset:precompile. 如果您对资产进行了更改,则需要rake asset:precompile。

If you're having a rack up issue, make sure you have this file => config.ru and the contents should look like this. 如果您遇到机架问题,请确保您有此文件=> config.ru,内容应如下所示。

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run SampleApp::Application

I'm relatively new to Rails and Heroku, but as I mentioned above, if you're following the tutorial's directions, Heroku is a snap and the directions most definitely work. 我对Rails和Heroku相对较新,但正如我上面提到的,如果你按照教程的说明进行操作,那么Heroku很容易实现。 If not, I highly recommend getting started there! 如果没有,我强烈建议您从那里开始!

enter link description here 在此输入链接描述

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

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