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

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

Related

Heroku CLI throws an error whenever I try to do anything: "Please specify a version along with Heroku's API MIME type"

As of this morning, without having change anything in my Heroku CLI setup, I received the following error when I tried to run:
heroku logs -t -app <app_name>
! Please specify a version along with Heroku's API MIME type. For example, Accept: application/vnd.heroku+json; version=3.
I have since tried updating both heroku and heroku-toolbelt via brew upgrade heroku and brew upgrade heroku-toolbelt, but this did not solve the issue.
I get this error essentially whenever I try to do anything with heroku CLI, including heroku logs, heroku apps, heroku login, and heroku auth:login.
I am running MacOS, and the error posted is the only information that I am getting back from Heroku.
This discussion here: How can I specify heroku's MIME type? pertains to upgrading Heroku in Ubuntu and does not solve my issue.
I had the same problem -- but installing the new Toolbelt did not work at first. There was one other step I needed to do.
from: https://devcenter.heroku.com/articles/heroku-cli
It has instructions for each platform on installing the new cli -- and says you need to run: which heroku in order to verify the proper version is running. In my case I also needed to do a gem uninstall heroku in order to get everything working, as it was running the gem binary instead of the newly installed heroku-cli binary.
If you were using heroko Plugin for intellij
I tried alot to make it work !
From here official response
#emzeidan thanks for the report. This plugin is deprecated, and uses an old version of the Heroku API that has been shut down. Please recommend to your users that they use one of the alternative deployment mechanisms described in our DevCenter article on WAR deployment. If you can remove from the plugin from any Bamboo marketplace (or similar thing) that would be helpful too. Thanks.
This was on Sept-2017
I run the 'heroku --version' command and the toolbelt automatically updates the client. After that the login was ok.
I had the same problem on macOS Sierra 10.12.3 when I installed heroku via brew.
To get round it I ran brew uninstall heroku-toolbelt then installed via the Mac installer at https://devcenter.heroku.com/articles/heroku-cli#macos and it works fine now.
Have you specified the heroku gem in your Gemfile? If yes, then remove it.
And then, install Heroku CLI for https://devcenter.heroku.com/articles/getting-started-with-ruby#set-up and run your command.

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.

Upgrading Bundler Version on Heroku

I need an updated version of bundler on my heroku application (cedar 14) and I haven't seen any reason why I can't do this. I'm stuck at 1.6.6 which is a couple months old and I need the most up to date version.
I need to specify a source: option for one of my gems and the older version of bundler doesn't allow this. Additionally, running heroku run gem update bundler successfully updates but 'heroku run bundle -v' yields 1.6.6.
Why?
You can modify the bundler version used by specifying the Ruby Buildpack on Heroku:
If you see that a different version of Bundler is being used by your
application than is listed in the Ruby Support article, your
application might be configured to use the master branch of the Ruby
buildpack for deployments.
To check which buildpack is configured, use the heroku buildpacks
command:
> heroku buildpacks
> === hidden-temple-25627 Buildpack URL https://github.com/heroku/heroku-buildpack-ruby.git
The example output shows that an unreleased version of the buildpack
is being used. To switch to the supported version, set the buildpack
as follows:
heroku buildpacks:set heroku/ruby Buildpack set. Next release on
hidden-temple-25627 will use heroku/ruby. Run git push heroku master
to create a new release using this buildpack.
You can verify that the new buildpack has been set by typing:
> heroku buildpacks
> === hidden-temple-25627 Buildpack URL heroku/ruby
Another reason your app might not be using the currently supported
Bundler version is if it is configured to deploy using a different
buildpack URL. This will happen if the BUILDPACK_URL config var is
set.
> heroku config:get BUILDPACK_URL BUILDPACK_URL:
> https://github.com/heroku/heroku-buildpack-ruby.git
If you see any value, then you are using a custom buildpack. If this
value is set to a “multi buildpack” such as
https://github.com/heroku/heroku-buildpack-multi then you will need to
check the .buildpacks file to see what buildpacks are used in
deployment. If you are using this method of deployment we recommend
that you instead follow the guidance in the Using Multiple Buildpacks
for an App article.
The officially deployed Ruby buildpack will sometimes lag behind
master for a few days.
Other than that it can not be directly configured:
Why can’t the Bundler version be configured?
Different versions of Bundler have different known bugs and slightly
different behavior. The Bundler version on Heroku is carefully
curated. A balance needs to be struck between supporting new Bundler
features and stability. The work we put into curating the Bundler
version ensures maximum stability, and avoids deprecation and
notification cycles on Bundler as it changes, or as bugs are fixed or
security issues are patched by Heroku.
The Ruby experience on Heroku is provided by the Heroku Ruby
Buildpack. This is the tool that installs a version of Bundler and
runs all the commands needed to get your application set up. The
buildpack relies on publicly exposed internals of Bundler. It is
tested and known to work against the currently specified version of
Bundler. If you were to take a modern buildpack and use it with an
older version of bundler, you would be likely to see unpredictable
results.
https://devcenter.heroku.com/articles/bundler-version

Cannot fork an older heroku app

I have a ruby on rails app on heroku that I wanted to make some updates to. I was hoping to fork the app and test my changes on a new staging clone before I update the live site.
When I try the command:
heroku fork -a source-app new-staging-app
I get the error:
! 'fork' is not a heroku command.
And when I use "heroku help", fork does not appear as one of the choices.
When I'm signed in to another account and working on a more recent app, the fork command is available as a command.
The app I'm trying to fork is on the cedar stack and it's currently using rails 3.2.11.
Any idea why 'fork' might not be available with this app?
The 'fork' command was added to the heroku toolbelt in 2013. Install the latest version of the heroku toolbelt on the account in question to be able to use the fork feature: https://toolbelt.heroku.com

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

Resources