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

I'm brand new to Rails and am following this tutorial on how to make Rails applications. I can't get the database to migrate to my heroku apps.
I'm currently at the beginning of chapter 3, trying to set up an app to use for the rest of the course.
I've been following the tutorial perfectly, and, so far, I've already built two apps and deployed them to heroku and migrated the data just fine, but the third time it's not working.
I was able to make the heroku page and push the app to it, but I just can't migrate the data.
I typed:
heroku run rake db:migrate
and got this error:
/usr/bin/env: ruby.exe: No such file or directory.
I'm assuming this means it's looking for the file in that directory and not finding it. How do I change where it's looking?
I checked "windows heroku run rake db:migrate error “/usr/bin/env: ruby.exe: No such file or directory”" and did what the answers recommended, that is, change "ruby.exe" to "ruby" in bin/bundle, bin/rails, and bin/rake, but that didn't work.
Any other tips? I have been stuck on this for hours. Thank you so much in advance.

The command is normally heroku run rake db:migrate. You should try that instead of heroku run rails db:migrate.
Make sure you've pushed your app to heroku. When it's pushing to heroku, make sure that it is also detected as a rails app. It's possible that heroku isn't detecting a rails app so the environment it sets up doesn't have ruby installed. But it may just be the error in the command name (rails instead of rake).

I had a similar problem on a repository I had ported over from windows.
It turns out that several scripts in the app's bin directory still had a shebang lines (#!/usr/bin/env ruby.exe) to ruby.exe instead of ruby. Once I fixed these scripts the problem went away.

On your local dev machine, before committing to git (and then pushing to Heroku), try changing the line endings to Unix line endings (rather than Windows line endings). On a *nix machine you'd do that by running dos2unix myfile.rb
If the line endings are wrong, the Linux loaded on Heroku will look for ruby^M and not for ruby, and will of course not find it, and give this exact error message.

Related

Heroku : This version of the API has been Sunset. is displayed when heroku pg:psql

When I try to use heroku pg:psql, the following error is displayed.
! This version of the API has been Sunset.
! Please see https://devcenter.heroku.com/changelog-items/1147 for more information.
How can I access postgresql on Heroku?
heroku pg:psql command worked a few week ago.
I develop my Rails app on the Cloud 9.
I had the same issue with my ruby on rails project since last Friday.
However, i was able to resolve this error message by update my heroku toolbelt on my mac os.
*Hint, if your heroku file was installed in project gem. you will need to delete that file.
Use command which heroku to identify where is the heroku file. if it is inside the .rvm folder that means your project is still using outdated heroku file. and simply remove it and then ran an new install heroku cli should fix this error.
Let me know if this works for you.

Trying to Execute Ruby Code for the first time.

Project:
https://github.com/jmopr/job-hunter
Background:
Took only 2 intro course on Java 7 years ago.
So I was browsing GitHub and ran across this nifty project that deals with scraping & applying for jobs on indeed.com.
The question is, how do you run it? Here is what I tried to do:
Tried to execute applier.ru I figured I was doing something wrong after getting:
/home/shap/Desktop/job-hunter-master/applier.rb:19:in initialize': uninitialized constant JobApplier::Job (NameError)
from /home/shap/Desktop/job-hunter-master/applier.rb:169:innew'
from /home/shap/Desktop/job-hunter-master/applier.rb:169:in `'
Something was missing, so looking around I found the bin folder and tried executing /bin/setup.ru but i ran into this error:
== Preparing database ==
/var/lib/gems/2.3.0/gems/railties-4.2.5.1/lib/rails/application/configuration.rb:110:in database_configuration': Cannot loadRails.application.database_configuration`:
Could not load database configuration. No such file - ["config/database.yml"] (RuntimeError)
Are we supposed to generate our own database file? how would we do that?
Any help or even a push in the right path is deeply appreciated.
You are supposed to generate your own database configuration. It should be stored at config/database.yml. It's a file that specify where's your db server, what's the name of the database and what should be the credentials to access it. Google "rails database.yml example".
Once you have that, creating your actual database is as easy as running these commands
rake db:create
rake db:migrate
There may be many-many other different obstacles on your journey of making this application run. Things that are obvious to rails devs, but arcane to total strangers. I suggest finding and completing a ruby on rails tutorial.
This is ruby on rails project,
after checkout you need install all required dependencies, with command
bundle exec install
Run project you can with command
./bin/rails server
If project is started successful, you can access it with browser using address http://localhost:3000
more about rails you can find there http://guides.rubyonrails.org/getting_started.html
http://guides.rubyonrails.org/getting_started.html

No File or Directory Found when Deploying a Rails Application to Heroku

I am trying to deploy a Rails application created from Windows (Win 7) to Heroku. Unfortunately, I am experiencing an error in Heroku saying that No such file or directory found when referring to Ruby.
I updated the first line of bin/bundle, bin/rails and bin/rake from #!/usr/bin/env ruby.exe to #!/usr/bin/env ruby but it still did not work out. I then modified this line to #!/usr/local/bin/ruby but still got the same problem.
What are the steps involved to solve this issue please or Windows is a no-go for RoR?
The application is very simple and so far it does not use a database (not even sqlite3)

Capistrano user-related problem

I'm deploying a rails application using Capistrano to a shared server (on WebFaction). This means there are several different Ruby version installed there.
Everything works fine until I want to run some rake tasks. These tasks fail by saying I don't have the right RubyGems version.
From this thread I understood that fixing it would be as easy as adding the full path to the correct rake folder to my rake commands. I tried that but failed again, now because the Ruby interpreter that is used is the wrong one.
I assumed that capistrano would use the username/password I gave it to run commands on the server but it seems not to be the case.
Am I missing something? How can I fix that?
Thanks!
This is indeed a path issue. I solved it by symlinking my ruby, rake, and rails executables to my path. For instance, if the executables that you want (but are failing to work) are located at /opt/ruby/bin/ruby, you'll symlink it to:
ln -s /opt/ruby/bin/ruby /usr/local/bin/ruby

RoR app running on mongrel development but not production

This is my first stab at Ruby on Rails. Just deployed a very simple app to Heroku.
The thing is that my app runs flawlessly on mongrel development; When I run it with "mongrel_rails start -e production" however, I get the error "We're sorry, but something went wrong."
For the life of me, I couldn't debug this. Heroku logs is not returning anything, the Exceptional addon in Heroku is not returning anything, and I cannot find mongrel.log on my Windows machine (when I run mongrel using: mongrel_rails start -e production -d"
I'm using Rails 2.3.5 and sqlite3 with bundler to pack my gems.
I was told that probably rails is not booting up correctly. I can't find any other way to diagnose this. Any ideas?
Thanks,
ANaimi
Take a look at your log/production.log file. That should contain detailed information about what's going on. It will usually contain a line that specifies the name of a gem that needs to be installed.
Heroku doesn't use mongrel, so I'm assuming that's what you're trying to do to figure out why it isn't working when you push it to heroku.
I've found, in most cases, my heroku problems have been because of uninstalled gems. Make sure you create a gem manifest.
Try tailing logs while booting up. From the terminal in the log directory do: tail -f *.log and then launch the app from another terminal (likely it's development.log since you're probably running in development mode.)
Not sure if this got definitively answered, however, check your '%app_root%/config/environments/' folder, and compare 'development.rb' to 'production.rb'.
Make sure that you have all necessary settings in the production.rb file - might have missed something important there.

Resources