Heroku: Could not find a JavaScript runtime - ruby-on-rails

In heroku app log I get:
2011-11-25T15:14:08+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/execjs-1.2.9/lib/execjs
etect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a li
(ExecJS::RuntimeUnavailable)
Are execjs and therubyracer gems needed to run rails 3.1 app on heroku?

Given the error message I'm guessing this is a Rails 3.1 on the old stack, called Bamboo.
Heroku recommends the cedar stack for Rails 3.1 and they have a tutorial here on how to get that going.

You need to be using the heroku cedar stack and not bamboo.

Install JavaScript runtime environment in your systems by using following steps, as this is best way to solve the issue:
wget http://nodejs.org/dist/node-v0.1.31.tar.gz
tar xfv node-v0.1.31.tar.gz
cd node-v0.1.31
./configure
make
make install

Related

Installing Commonmarker (Ruby wrapper for a C app) on Heroku

I am currently trying to install the CommonMarker gem on my Heroku app. I have included it in my Gemfile, and as I expected, it failed to bundle install due to cmake not being present in Heroku. I managed to install cmake on my development environment, but am at a loss how to do so for Heroku.
As I understand it, cmake is only needed during the bundle process, which will create the binary used by libcmark, which is in turn used by Commonmarker. I have read something about buildpacks, but that seems to be mainly about customizing the development environments.
Any help would be greatly helpful. Thanks.
Login to Heroku and go to the settings page for your app. Add in the following order under the Buildpacks section.
https://github.com/ello/heroku-buildpack-cmake
Ruby (official Heroku version)
Note: I was able to push to Heroku and the build was successful, but the app slug size bloated dramatically.

Heroku/Rails: How to install the GNU Scientific Library (GSL) on Heroku?

I need to install the GSL library on Heroku running a Rails (4.0.2) app to use some gems that depend on it.
Goal:
Install the GSL library to work with GSL and Similarity gems in Heroku.
Tried approaches:
Installing Ruby / GSL in Heroku Application: Heroku crashes after deploy. GSL gem is unable to find the lib. Trace: http://pastebin.com/CPcMUdCa
Tomwolfe's Heroku's Ruby buildpack adapted for using couchbase: Same issue.
Building Dependency Binaries for Heroku Applications: Vulcan is deprecated. More info on Heroku's Devcenter and on Github
I've tried following these steps (compiling binaries):
GSL 1.15 downloaded from ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz
Uncompressed and cd gsl-1.15
./configure
make clean
make
sudo make install
It works on my local environment but not in Heroku. Heroku doesn't allow sudo but it allows access with heroku run. The problem is that the file system is ephemeral and the dyno will only live as long as your console session.
Update:
I've also tried building my own Heroku Buildpack but I couldn't make it work. I tried using multipacks. I'm not a Heroku Buildpack expert so maybe it's the problem, I'm learning more about it to make a simple repository with an example and an extended explanation of this issue.
I had to use gsl1.16 on heroku and here is how I solved it:
First added gsl1.16 buildpack to the lists of buildpacks like
heroku buildpacks:add --index:3 git://github.com/gregory/heroku-gsl-buildpack.git#gsl-1.16
Which adds to my list of buildpacks, in my case got nodejs and ruby already. Hence --index=3
Then had to set LD_LIBRARY_PATH on heroku like
heroku config:set LD_LIBRARY_PATH=/app/vendor/gsl/lib
which points to 1.16. Seen around that some people use /app/vendor/gsl1/lib but wasn't my case.
and that's it.
I made a heroku buildpack a couple months ago for 1.15 and 1.16
just do:
heroku buildpacks:set git://github.com/gregory/heroku-gsl-buildpack.git#gsl-1.16
or
heroku buildpacks:set git://github.com/gregory/heroku-gsl-buildpack.git#gsl-1.15
You'll need to use a custom buildpack. Buildpacks allow you to define any additional dependencies outside of your project and package them with your slug which is used by the dynos. The buildpack you linked to (https://github.com/tomwolfe/heroku-buildpack-gsl-ruby) would be your best bet in getting everything working. I would open issues on their github repo if you are having issues, hopefully they can help you out

Heroku can't find libruby-1.9.1.so.1.9

I'm running through a ruby on rails tutorial, and I just installed the Heroku toolkit.
My problem is that whenever I try "Heroku login", or whatever heroku command, I get :
ruby1.9.1: error while loading shared libraries: libruby-1.9.1.so.1.9: cannot open shared object file: No such file or directory
I remember having cleaned my ruby installations recently, so I wonder if I just miss some libs that I have deleted or something, but I haven't been able to find anything satisfying about that.
Do you have an idea how to get out of this situation, and be able to use Heroku ?
I managed to make heroku work by installing it with gem :
gem install heroku
instead of :
sudo apt-get heroku
It seems like heroku was trying to use a ruby version out of rvm (but i deleted the ruby version which was installed before rvm). Now the gem installation took care of that.

libjpeg with image_optim gem on Heroku Cedar Stack (Ruby buildpack)

I'm trying to get the image_optim gem to work with a Rails 4 app on Heroku's Cedar stack to optimize png/gif/jpeg images.
I threw the required binaries (advpng, gifsicle, jpegoptim, jpegtran, optipng, pngcrush, pngout) into /bin and set ENV['PATH'] = "#{Rails.root}/bin:#{ENV['PATH']}" in an initializer. This works for gifs and pngs, but I'm running into problems with jpegs.
In the rails console I get:
irb(main):001:0> `jpegoptim`
jpegoptim: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
How should I go about installing libjpeg on Heroku?
The correct way to deploy binaries to Heroku is to use buildpacks:
https://devcenter.heroku.com/articles/buildpacks
Use this one if you want to package up multiple binaries:
https://github.com/ddollar/heroku-buildpack-multi
There are a number of buildpacks already created for various binaries, but none for the ones you have listed.
I have created a gem that allows you to run image_optim on heroku:
https://github.com/mooktakim/image_optim_bin
You're probably looking for this: Heroku Image-Optim Buildpack
Or this: https://github.com/bobbus/image-optim-buildpack

Running ruby 1.9.2 on Heroku

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

Resources