Running ruby 1.9.2 on Heroku - ruby-on-rails

I'm trying to create a new app on heroku but it seems no matter what I do heroku runs ruby 1.9.1 rather than 1.9.2
I've created my app...
heroku create writings --stack cedar
Then I've pushed my develop branch to master on heroku for testing
git push heroku develop:master
But the app runs with errors... looking in the heroku logs.. this seems to be the offending error.
/app/vendor/bundle/ruby/1.9.1/gems/execjs-1.1.3/lib/execjs/runtimes.rb:43:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
Which shows that it's running ruby 1.9.1 does it not?
If I run heroku config it shows...
heroku config
DATABASE_URL => postgres://mxlvaczibv:wMtsU7TrPMQM5n-X5SfX#ec2-50-19-226-179.compute-1.amazonaws.com/mxlvaczibv
GEM_PATH => vendor/bundle/ruby/1.9.1
LANG => en_US.UTF-8
PATH => vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV => production
RAILS_ENV => production
SHARED_DATABASE_URL => postgres://mxlvaczibv:wMtsU7TrPMQM5n-X5SfX#ec2-50-19-226-179.compute-1.amazonaws.com/mxlvaczibv
Is this not showing it is running 1.9.1? I'm totally confused... I thought the cedar stack ran 1.9.2. Any help appreciated.
Thanks, mark.

It does not show that it is running Ruby 1.9.1. Because the standard library changed very little between 1.9.1 and 1.9.2, the same path is used for both of them. You will notice this is not just on Heroku.
It looks like execjs is expecting to have a JS runtime installed on the system. Apparently Celadon Cedar does have one (NodeJS), but it won't work until rails 3.1rc5 arrives. Until then, follow the intructions in this answer.

I am using Ruby 1.9.2 and Heroku as well. I have this in my Gemfile. I remember having some sort of javascript errors when trying to deploy to Heroku before as well, I'm pretty sure this solved it.
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
end

Try using:
heroku create --stack bamboo-mri-1.9.2

Related

The `heroku' command exists in these Ruby versions:

I'm having major issues with the heroku toolbelt. I'm using the cedar 14 stack and when I am trying to use a ruby version that isn't ruby 2.0.0-dev I get this error.
rbenv: heroku: command not found
The `heroku' command exists in these Ruby versions:
2.0.0-dev
I need heroku to be working with ruby 1.9.3 and I don't think cedar 14 supports that version of ruby. Can someone explain first, why I am only allowed to use heroku with ruby 2.0.0-dev and also how I can install a older stack that supports ruby 1.9.3?
The problem is that there are two heroku executables on your system: one in system paths such as /usr/local/bin/heroku (provided by Toolbelt), and one in rbenv's shims because Ruby 2.0.0-dev had "heroku" gem installed.
Because rbenv's shims directory usually have higher precedence, it will block invocation from ever executing the heroku executable provided by Toolbelt.
The solution is to uninstall any instance of "heroku" gem and relying solely on Toolbelt for all heroku usage on the command line:
for v in `rbenv whence heroku`; do RBENV_VERSION=$v gem uni heroku -ax; done
rbenv rehash
which heroku
You can use 1.9.3 on the cedar stack according to this. The heroku toolbelt is installed as a executable not a ruby gem. How are you trying to execute the command? You should be able to use it from the terminal such as heroku run rake db:migrate etc.

Heroku removes bundler when deploy

I'm in trouble with deployment of my ruby-on-rails app on heroku.
Deploy failed with following logs.
Starting process with command bundle exec thin start -R config.ru -e staging -p 6882
bash: bundle: command not found
And I noticed when deploy, bundler(1.3.2) is removed and bundler(1.5.2) is used even if I specify bundler version as '1.3.2'.
When deploy, Using bundler(1.5.2) is shown but there is no bundler in heroku run 'gem list'.
This is happen after I pushed the commit that includes some gem's updates.
After that deploy, all deploys are failed even if I deloy the commit that worked well before.
Do you have a ruby definition in your gemfile like so?
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.15'
.....
if you do, heroku will try to load bundler 1.5.2
try to update bundler like so
gem update bundler
then commit & push to heroku
I hope that helps
Thank you, everyone.
I fixed up this problem.
I tried all solutions in this post but couldn't get fixed, so I asked the heroku's support with detail information.
It is because I'm using the custom buildpack that not support Bundler 1.5.2.
So, I configure an app to use the Official Ruby Buildpack
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby

Is it possible to run my Rails app on Heroku with Ruby 1.9.3? If so, how?

I tried this tip: https://github.com/thoughtbot/laptop/pull/14#issuecomment-3192270 .
On deploy I see
-----> Using RUBY_VERSION: ruby-1.9.3-p0
But my logs show the environment variable is not respected
INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
Hacky / experimental solutions accepted!
Edit: I am on the cedar stack.
Here's an update for everyone referencing this question... Heroku now allows you to specify your ruby version in your Gemfile, thanks to their addition to the latest version of bundler.
First run:
gem install bundler --pre
then add ruby '1.9.3' to your Gemfile as such.
source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.3'
The full release from Heroku with details is at http://blog.heroku.com/archives/2012/5/9/multiple_ruby_version_support_on_heroku/
Right, so Ruby 1.9.3 is definitely possibly. As you said hacky/experimental solutions were accepted - this is definitely one of them.
It's actually really simple;
Enable Heroku Labs's user_env_compile feature for your application.
Set a heroku config variable to RUBY_VERSION to ruby-1.9.3-p0 (heroku config:add RUBY_VERSION=ruby-1.9.3-p0)
ENSURE that the heroku PATH config variable has bin at the front (heroku config:add PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin)
When you next deploy you should see your application using 1.9.3 - the deployment output will show this too;
-> Heroku receiving push
-----> Ruby/Rails app detected
-----> Using RUBY_VERSION: ruby-1.9.3-p0
-----> Installing dependencies using Bundler version 1.1.rc.7
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Since May 10 it is possible to use Ruby 1.9.3 in an easier way. Just take a look at Heroku's blog:
http://blog.heroku.com/archives/2012/5/9/multiple_ruby_version_support_on_heroku/
I was able to get a Rails 3.2 app running on Ruby 1.9.3-p0 on Heroku cedar today
I followed the steps on
http://railsapps.github.com/rails-heroku-tutorial.html
ran into a problem locally with 1.9.3 and openssl
but was able to get an app deployed and working
http://mccaffrey-rails32-193.herokuapp.com
no Procfile
thin and pg in Gemfile
I added some debug output so you can see the rails and ruby version info
Its crazy that a basic rails app slug size is 28.9MB!
I had the same problem: Specifying 1.9.3 in my Gemfile, but it was using 1.9.2. This fixed it:
heroku config:add PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
According to the Heroku Cedar stack definition here Cedar currently only supports MRI 1.9.2. Have you tried contacting Heroku support? They're generally pretty responsive.
Edit: it's possible to 'fool' the platform sometimes into running some binaries such as running Haskell on Heroku so if you're feeling really dedicated you might be able to package something up. I imagine this isn't too easy with MRI though.

Heroku gets error with Ruby Mongrel gem

Can't quite find the answer for my error in related posts.
I'm working my way through the on-line version of the Ruby on Rails Tutorial, Chapter 2
http://ruby.railstutorial.org/chapters/a-demo-app#top
and I'm near the bottom where I've created a small 2-table database and committed it to git. But it fails when I try to deploy with 'git push heroku master'. The same command worked previously before I added the tables to the app (and before I got Mongrel to work on the demo_app, I think).
My bundle includes Ruby 1.8.7, Mongrel 1.1.5 and sqlite3 1.3.3. I'm getting the line:
Installing mongrel (1.1.5) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions':ERROR: Failed to build gem native extension. (Gem:Installer::ExtensionBuildError).
How do I get around this problem? Can Heroku handle Mongrel at all? Or is it due to having a sqlite3 database? Why does the error mention Ruby1.9.2 when that's not in my bundle?
You don't need to use mongrel at all, and should simply remove it from your Gemfile. Whenever you see a reference to starting mongrel in your tutorial, just use ./script/server instead (or rails server if you're on Rails 3). It will run WebBrick, and that's good enough for development work.
If you really want to retain mongrel for local use you can group it as follows in Gemfile.
group :development do
gem "mongrel"
end
Note that you will likely still have to tell Heroku to not bundle your development gems or you'll run into the same error. If you're on the Cedar stack, then just get rid of the mongrel gem entirely.

How can I choose Ruby version on Heroku?

I use Ruby 1.9.x syntax in my Rails 3 app, but after pushing it to Heroku it crashes due to older Ruby version (1.8). How can I control it?
Heroku's current stack, Cedar, uses 1.9.2 by default. Cedar also supports specifying the Ruby version in your Gemfile. Currently, 1.9.2 and 1.9.3 are valid options.
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
...
More details are available in the Ruby support article: https://devcenter.heroku.com/articles/ruby-support
If you are currently using Aspen or Bamboo, you can switch to 1.9.2 by using the stack:migrate command:
$ heroku stack:migrate bamboo-mri-1.9.2
You cannot automatically migrate to the Cedar stack at this time, but there is a guide on how to do so: https://devcenter.heroku.com/articles/cedar-migration
You can now explicitly specify a Ruby version on Heroku.
Simply setup your Gemfile as so
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
# Gems go here
I wanted to use the version I already had defined in the .ruby-version file so I ended up creating a buildpack that can be used before heroku-buildpack-ruby that injects the version from the .ruby-version into the Gemfile. It also support versions without patch or aliases.
https://github.com/platanus/heroku-buildpack-ruby-version
This way you can have your version defined only in one place.

Resources