windows heroku run rake db:migrate error “/usr/bin/env: ruby.exe: No such file or directory”

后端 未结 5 572
清歌不尽
清歌不尽 2020-11-27 21:18

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

相关标签:
5条回答
  • 2020-11-27 21:50

    Try this:

    sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
    

    and then install Nokogiri:

    gem install nokogiri
    
    0 讨论(0)
  • 2020-11-27 21:53

    I had this same problem, changed ruby.exe to ruby in the three files as described above, executed the

    
        git push heroku master
    
    step, which told me everything was up to date. Trying the
    
        heroku run rake db:migrate
    
    step again, it still didn't work; I got the same error about no such file or directory for ruby.exe. I examined my gemfile.lock as directed, but didn't see anything that looked windows-y.

    I then executed these:

    
        git add .
        git commit -m "My comment"
    
    and tried again with
    
        git push heroku master
    
    This time, boatloads of messages went by, including:
    
        Removing Gemfile.lock because it was generated on Windows.
    
    so perhaps there was something wrong with it and I just didn't know what I should be looking for in it.

    Trying again to

    
        heroku run rake db:migrate
    
    looks to have worked, as I got
    
        Running rake db:migrate attached to terminal... up, run.3260
        ==  CreateUsers: migrating ====================================================
        -- create_table(:users)
           -> 0.0409s
        ==  CreateUsers: migrated (0.0412s) ===========================================
    

    My best guess is that the change to remove the .exe from bundle, rake, and rails did not actually get pushed up on the first try of git push heroku master and the git add . and git commit -m "My comment" were necessary to make it get pushed up. This is my first attempt at anything with git/heroku/ruby, so I don't know enough to say why the other two commands were required, but leave my experience documented here in case it helps anybody else.
    Thanks so much for the clue above that it was the .exe in those three files that caused the problem.

    0 讨论(0)
  • 2020-11-27 21:56

    I had a similar issue and as others have already stated, changing the below helped.

    #!/usr/bin/env ruby.exe to #!/usr/bin/env ruby

    However, I also needed to remove some hidden carriage returns which were still present from developing on Windows originally (I guess?).

    I used dos2unix to do this.

    dos2unix bin/bundle bin/rake bin/rails
    

    After that, I committed my changes, pushed to heroku and all was good.

    0 讨论(0)
  • 2020-11-27 21:57

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

    bin/bundle
    bin/rails
    bin/rake
    

    Instead

    #!/usr/bin/env ruby.exe
    

    must be

    #!/usr/bin/env ruby
    

    That's why is error:

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

    Then you do successfully:

    heroku run rake db:migrate
    

    It's work for me.

    0 讨论(0)
  • 2020-11-27 21:58
    bin/bundle
    bin/rails
    bin/rake
    

    Instead

    #!/usr/bin/env ruby.exe
    

    must be

    #!/usr/bin/env ruby
    

    (thanks to previous post)

    make sure there are no references to windows in the gemfile.lock - they can just be deleted

    then

    git push heroku master
    

    if there are still problems use

    heroku logs (copying text to a text editor makes it easier to cut and paste for solutions)

    0 讨论(0)
提交回复
热议问题