title: windows heroku run rake db:migrate error "/usr/bin/env: ruby.exe: No such file or directory"
body: <p>I'm pretty new to Rails here and I've followed <a href="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book" rel="nofollow noreferrer">Ruby on Rails Tutorial</a> 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!)</p>
  
  <p>However, once I decided to push to Heroku, I've been pulling my hair out. Prior to pushing to Heroku, I did the standard:</p>
  
  <pre><code>c:\Sites\elms&gt;git add .
  c:\Sites\elms&gt;git commit -m "My comment"
  c:\Sites\elms&gt;git push
  c:\Sites\elms&gt;git push heroku master
  </code></pre>
  
  <p>I've downloaded and installed the Heroku Toolbelt (not <code>heroku</code> gem.) The first error told me I needed to make sure that my <code>Gemfile</code> specified Ruby >= 1.9.3, so I added "ruby 1.9.3" to the top of my <code>Gemfile</code>:</p>
  
  <pre><code>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 =&gt; [:mswin, :mingw], :require =&gt; 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', '~&gt; 1.0.0rc3'
  end
  
  group :test do
    gem 'capybara'
    gem 'factory_girl_rails'
    gem "shoulda-matchers"
  end
  
  group :assets do
    gem 'sass-rails',   '~&gt; 4.0.0.beta1'
    gem 'coffee-rails', '~&gt; 4.0.0.beta1'
    gem 'uglifier', '&gt;= 1.0.3'
  end
  
  gem 'jquery-rails'    
  gem 'turbolinks'
  gem 'jbuilder', '~&gt; 1.0.1'
  </code></pre>
  
  <p>The push finally worked without any issues, but when I tried to migrate the database, I got the following:</p>
  
  <pre><code>c:\Sites\elms&gt;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
  </code></pre>
  
  <p>I have also tried: <code>heroku run bin/rake db:migrate</code>, and it gives same error. I am using <a href="https://devcenter.heroku.com/articles/rails4" rel="nofollow noreferrer">Getting Started with Rails 4.x on Heroku</a> to push my Rails 4 app to Heroku. Any help would be greatly appreciated!</p>
  
  <p>Oh, I also had an issue after running: </p>
  
  <pre><code>c:\Sites\elmx&gt;gem install rails --pre
  </code></pre>
  
  <p>I solved this by adding <code>C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\bin;</code> 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:</p>
  
  <pre><code>rails -v
  rails g controller User
  </code></pre>
  
  <p>But if I typed just:</p>
  
  <pre><code>rails
  </code></pre>
  
  <p>It would give me all of the commands I could use (as if running <code>rails -h</code>)</p>
  
  <p>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.</p>
  
  <p>EDIT 1:</p>
  
  <p>I just deleted my user Path environment variable and modified my system Path environment variable to look like such:</p>
  
  <pre><code> C:\RailsInstaller\Ruby1.9.3\bin;C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\Heroku\bin
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>c:\Sites\elms&gt;ruby -v
  ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
  
  c:\Sites\elms&gt;rails -v
  Rails 4.0.0.beta1
  
  c:\Sites\elms&gt;heroku -v
   !    `-v` is not a heroku command.
   !    Perhaps you meant `-h`.
   !    See `heroku help` for a list of available commands.
  
  c:\Sites\elms&gt;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:\Sites\elms&gt;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
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <p>So I got a little further in this venture. I found out that I could execute:</p>
  
  <pre><code>c:\Sites\elms&gt;heroku run bash
  ~ $ cd bin
  ~/bin $ ruby rake db:migrate
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>c:\Sites\elms&gt;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
  </code></pre>
  
  <p>This is getting really frustrating. I have no clue what the heck <code>/usr/bin/env</code> is. The only thing I can guess is that it's like <code>PATH</code> for Windows. If this is the case, why does the server not know where <code>ruby.exe</code> is?</p>
  
  <p>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.</p>