windows heroku 运行 rake db:migrate 错误“/usr/bin/env: ruby​​.exe: 没有这样的文件或目录" [英] windows heroku run rake db:migrate error "/usr/bin/env: ruby.exe: No such file or directory"

查看:16
本文介绍了windows heroku 运行 rake db:migrate 错误“/usr/bin/env: ruby​​.exe: 没有这样的文件或目录"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Rails 还很陌生,我一直在关注 Ruby onRails 教程 中的大部分内容.从那以后,我决定制作自己的应用程序,但使用的是测试版的 Rails 4 gem.我已经在我的本地机器(Windows 7)上安装了 PostgreSQL 并完成了开发.一切都很好!(我对 Rails 的热爱远胜于我赖以谋生的 C#、ASP、.NET 工作!)

I'm pretty new to Rails here and I've followed Ruby on Rails Tutorial for most of it. I have since decided to make my own application, but using the Rails 4 gem in beta. I have installed PostgreSQL on my local machine (Windows 7) and done development. Everything works great! (I love Rails much more than C#, ASP, .NET work that I do for a living!)

但是,一旦我决定推向 Heroku,我就一直在拔头发.在推送到 Heroku 之前,我做了标准:

However, once I decided to push to Heroku, I've been pulling my hair out. Prior to pushing to Heroku, I did the standard:

c:Siteselms>git add .
c:Siteselms>git commit -m "My comment"
c:Siteselms>git push
c:Siteselms>git push heroku master

我已经下载并安装了 Heroku Toolbelt(不是 heroku gem.)第一个错误告诉我我需要确保我的 Gemfile 指定 Ruby >= 1.9.3,所以我在 Gemfile 的顶部添加了ruby 1.9.3":

I've downloaded and installed the Heroku Toolbelt (not heroku gem.) The first error told me I needed to make sure that my Gemfile specified Ruby >= 1.9.3, so I added "ruby 1.9.3" to the top of my Gemfile:

source 'https://rubygems.org'
ruby "1.9.3"

gem 'rails', '4.0.0.beta1'

gem 'pg'
gem 'haml-rails'
gem 'httparty'
gem 'devise', git: 'git://github.com/plataformatec/devise.git', branch: 'rails4'
gem 'cancan'
gem 'bootstrap-sass'
gem 'formtastic'
gem 'formtastic-plus-bootstrap'

group :development do
  gem 'annotate'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'guard-spork'
  gem 'guard-rspec'
  gem 'meta_request'
  gem 'rb-notifu'
  gem 'schema_to_scaffold'
  gem 'wdm', :platforms => [:mswin, :mingw], :require => false
  gem 'win32console'
end

group :development, :test do
  gem 'rspec-rails'
  gem 'pry'
  gem 'spork-rails', git: 'git://github.com/sahilm/spork-rails.git', branch: 'rails-4'
  gem 'spork', '~> 1.0.0rc3'
end

group :test do
  gem 'capybara'
  gem 'factory_girl_rails'
  gem "shoulda-matchers"
end

group :assets do
  gem 'sass-rails',   '~> 4.0.0.beta1'
  gem 'coffee-rails', '~> 4.0.0.beta1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'    
gem 'turbolinks'
gem 'jbuilder', '~> 1.0.1'

推送最终没有任何问题,但是当我尝试迁移数据库时,我得到了以下信息:

The push finally worked without any issues, but when I tried to migrate the database, I got the following:

c:Siteselms>heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2205
/usr/bin/env: ruby.exe: No such file or directory

我也试过:heroku run bin/rake db:migrate,它给出了同样的错误.我正在使用 Getting Started with Rails 4.x on Heroku 将我的 Rails 4 应用程序推送到 Heroku.任何帮助将不胜感激!

I have also tried: heroku run bin/rake db:migrate, and it gives same error. I am using Getting Started with Rails 4.x on Heroku to push my Rails 4 app to Heroku. Any help would be greatly appreciated!

哦,我运行后也有问题:

Oh, I also had an issue after running:

c:Siteselmx>gem install rails --pre

我通过将 C:RailsInstallerRuby1.9.3lib ubygems1.9.1in; 添加到我在 Windows 7 中的环境路径变量中解决了这个问题(它给了我一个尝试执行以下操作时找不到 rails 的错误:

I solved this by adding C:RailsInstallerRuby1.9.3lib ubygems1.9.1in; to my environment Path variable in Windows 7 (it was giving me an error that it couldn't find rails when trying to execute anything such as:

rails -v
rails g controller User

但如果我只输入:

rails

它会给我所有可以使用的命令(就像运行 rails -h)

It would give me all of the commands I could use (as if running rails -h)

我使用 Windows Rails 安装程序设置我的机器,然后安装 Rails 4 gem.这非常令人沮丧,我已经在互联网上搜寻了试图找到有同样问题的人.

I set up my machine by using the Windows Rails Installer, then installing the Rails 4 gem. This is extremely frustrating and I've scoured the internet trying to find someone with the same problem.

编辑 1:

我刚刚删除了我的用户路径环境变量并将我的系统路径环境变量修改为如下所示:

I just deleted my user Path environment variable and modified my system Path environment variable to look like such:

 C:RailsInstallerRuby1.9.3in;C:RailsInstallerRuby1.9.3lib
ubygems1.9.1in;C:Program Files (x86)gitcmd;C:Program Files (x86)Herokuin

将我的路径变量更新为上述并卸载 Heroku Toolbelt,然后重新安装它(因此 Heroku 部分位于路径变量中)并尝试以下操作:

Updated my path variable to the above and uninstalled Heroku Toolbelt, then re-installed it (hence why the Heroku piece is in the path variable) and tried the following:

c:Siteselms>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]

c:Siteselms>rails -v
Rails 4.0.0.beta1

c:Siteselms>heroku -v
 !    `-v` is not a heroku command.
 !    Perhaps you meant `-h`.
 !    See `heroku help` for a list of available commands.

c:Siteselms>heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2100
/usr/bin/env: ruby.exe: No such file or directory

c:Siteselms>heroku run bin/rake db:migrate
Running `bin/rake db:migrate` attached to terminal... up, run.2872
/usr/bin/env: ruby.exe: No such file or directory

编辑 2:

所以我在这次冒险中走得更远.我发现我可以执行:

So I got a little further in this venture. I found out that I could execute:

c:Siteselms>heroku run bash
~ $ cd bin
~/bin $ ruby rake db:migrate

然后运行 ​​rake 并在 Heroku 上迁移我的数据库.但问题越来越严重!我尝试导航到该页面,它告诉我有问题,所以我运行日志文件,这就是我得到的:

And that would then run rake and migrate my database on Heroku. But the problem gets worse! I try to navigate to the page and it tells me that there is something wrong, so I run the log file and this is what I get:

c:Siteselms>heroku logs
2013-03-16T05:34:20+00:00 heroku[api]: Enable Logplex by
2013-03-16T05:34:20+00:00 heroku[api]: Release v2 created by 
2013-03-16T05:34:36+00:00 heroku[slugc]: Slug compilation started
2013-03-16T05:35:37+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 13423 -e $RAILS_ENV`
2013-03-16T05:35:37+00:00 heroku[slugc]: Slug compilation finished
2013-03-16T05:35:37+00:00 app[web.1]: bash: bin/rails: No such file or directory

2013-03-16T05:35:39+00:00 heroku[web.1]: Process exited with status 127
2013-03-16T05:35:39+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 33539 -e $RAILS_ENV`
2013-03-16T05:35:40+00:00 app[web.1]: /usr/bin/env: ruby.exe: No such file or directory
2013-03-16T05:35:41+00:00 heroku[web.1]: Process exited with status 127
2013-03-16T05:35:41+00:00 heroku[web.1]: State changed from starting to crashed
2013-03-16T05:35:41+00:00 heroku[web.1]: State changed from crashed to starting
2013-03-16T05:35:44+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 23452 -e $RAILS_ENV`
2013-03-16T05:35:44+00:00 app[web.1]: /usr/bin/env: ruby.exe: No such file or directory

这真是令人沮丧.我不知道 /usr/bin/env 到底是什么.我唯一能猜到的是它就像 Windows 的 PATH .如果是这样,为什么服务器不知道ruby.exe在哪里?

This is getting really frustrating. I have no clue what the heck /usr/bin/env is. The only thing I can guess is that it's like PATH for Windows. If this is the case, why does the server not know where ruby.exe is?

我确实制作了一个非 Rails 4 应用程序,并且能够将其发布到 Heroku 并毫无问题地查看它.这真的让我很紧张.

I did make a non Rails 4 application and was able to post it to Heroku and view it with no issues. This is really getting on my nerves.

推荐答案

您需要在应用程序的第一行更改 3 个文件:

You need to change in your application first line of the 3 files:

bin/bundle
bin/rails
bin/rake

相反

#!/usr/bin/env ruby.exe

必须

#!/usr/bin/env ruby

这就是错误的原因:

/usr/bin/env: ruby.exe: No such file or directory

那么你就成功了:

heroku run rake db:migrate

这对我有用.

这篇关于windows heroku 运行 rake db:migrate 错误“/usr/bin/env: ruby​​.exe: 没有这样的文件或目录"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆