I'm working with an old Rails app that was initially built before Bundler and Gemfiles. Is it possible to push this app up to Heroku without a Gemfile? The app is in production on the Bamboo Stack and working without one. I'm trying to add a development environment on the Cedar Stack (Bamboo is now closed) and getting an error:
-----> Heroku receiving push
-----> Removing .DS_Store files
! Heroku push rejected, no Cedar-supported app detected
Is it no longer possible to push to Heroku without a Gemfile?
I'll add a Gemfile if that's what it takes.
The official word from Heroku Support:
Hi, yes you need a Gemfile for ruby apps; we don't have any gems
installed on the base system so that's how you specify them. That's
also how we detect it's a ruby app.
Also potentially useful: https://github.com/kch/gemfile-tool
Related
I’m updating the environment on Heroku and one of the buildpack we use is based on Ruby, which is no longer available by default in the new heroku-22 environment/stack (nor required by our PHP app).
From the docs:
[...] end users should add the Ruby buildpack prior to the buildpack in question (they will also need to ensure minimal Gemfile / Gemfile.lock files exist, so that the Ruby buildpack passes detection).
However I have no clue what those files should include as I have zero experience with Ruby. What would be a valid set of minimal Gemfiles to trigger Ruby installation on Heroku?
I suggest you don't use that buildpack at all. It's ancient, and third-party buildpacks are always a bit questionable, even if it's just because they often stop getting updated.
Here's what it claims to do:
This is a Heroku buildpack for vendoring just the mysql binary from the mysql-client-core deb package.
If you just need a mysql binary, you can use the apt buildpack to install it without worrying about Ruby or anything like that.
Add it as your first buildpack:
heroku buildpacks:add --index 1 heroku-community/apt
Create an Aptfile in the root directory of your project that lists the Ubuntu packages you wish to install, e.g.
mysql-client-core-8.0
Note that the buildpack does not do dependency resolution. If any packages you list have their own dependencies you may have to list them explicitly.
Commit, and redeploy.
You should see the Ubuntu packages you listed get installed before your main buildpack runs.
In any case, if you really want to make your application compatible with the Ruby buildpack you should be able to simply include an empty Gemfile in the root of your project:
The Heroku Ruby Support will be applied to applications only when the application has a Gemfile in the root directory. Even if an application has no gem dependencies it should include an empty Gemfile to document that your app has no gem dependencies.
A Gemfile.lock is not required.
Note that you'll need to manually add the buildpacks you require. I believe you'll want Ruby first, then the MySQL buildpack in your question, then whatever language your application is written in, which appears to be PHP:
heroku buildpacks:set heroku/php # Main buildpack; we insert others before it below
heroku buildpacks:add --index 1 heroku/ruby
heroku buildpacks:add --index 2 https://github.com/thoughtbot/heroku-buildpack-mysql.git
heroku buildpacks
# => Should print the buildpacks in the expected order
Edited
It turns out an empty Gemfile is not enough and a Gemfile.lock is actually required as well.
-----> Building on the Heroku-22 stack
-----> Using buildpacks:
1. heroku/python
2. heroku/ruby
3. https://github.com/thoughtbot/heroku-buildpack-mysql
4. heroku/php
5. heroku/nodejs
-----> Python app detected
-----> Using Python version specified in runtime.txt
-----> Stack has changed from heroku-20 to heroku-22, clearing cache
-----> No change in requirements detected, installing from cache
-----> Installing python-3.10.8
-----> Installing pip 22.2.2, setuptools 63.4.3 and wheel 0.37.1
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting supervisor
Downloading supervisor-4.2.4-py2.py3-none-any.whl (749 kB)
Installing collected packages: supervisor
Successfully installed supervisor-4.2.4
-----> Ruby app detected
grep: /tmp/build_bebc9aa2/Gemfile.lock: No such file or directory
-----> Compiling Ruby/NoLockfile
!
! Gemfile.lock required. Please check it in.
!
! Push rejected, failed to compile Ruby app.
! Push failed
An empty Gemfile will trigger the Ruby installation, however the heroku/ruby package itself does require a lock file.
The buildpack will detect your app as Ruby if it has a Gemfile and Gemfile.lock files in the root directory.
After some trial and error I figure out the following files work:
# Gemfile
source 'https://rubygems.org'
# Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
ruby
DEPENDENCIES
BUNDLED WITH
1.17.3
I have built a simple sinatra web app on my macbook. The deployment to heroku fails with the logs below. The problem is that I've already implemented their suggested fix (bundle lock --add-platform x86_64-linux) and I still get the same error message.
Any suggestions as to next steps would be very welcome. Thanks in advance.
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Ruby app detected
-----> Installing bundler 2.2.33
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-2.7.5
-----> Installing dependencies using bundler 2.2.33
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
Your bundle only supports platforms ["arm64-darwin-20"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
Bundler Output: Your bundle only supports platforms ["arm64-darwin-20"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
*Update
My local repo, with x86_64-linux in Gemfile.lock, is out of sync with the remote repo on github that I have been trying to deploy from. Other files are out of date too. Concerningly, I have both pushed and pulled recently, as well as deleted the remote repo, created a new one and pushed again. Git is telling me that both the local and the remote repos are up to date with each other, when they are obviously not.
I've tried pushing directly to heroku from the command line but hit the same platform error as above.
I've built a Ruby app for Twitter. I have a Gemfile and the Gemfile.lock that bundler created. This is the contents of the Gemfile
source 'https://rubygems.org'
gem 'twitter'
When I try to push the app to Heroku, it fails with:
App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/ruby.tgz
I tried removing the buildpack from the Heroku settings. If I do this, it fails because it cannot detect the buildpack.
I can't see what is wrong here. Help gratefully received.
I solved this by adding a new line to the end of the gemfile
I have a Node project that is using Bundler and Guard to handle my pre-compilations steps.
This means that I have a Gemfile in the root of my project along with the package.json file.
My problem is that Heroku believes that my project is a Ruby app, just because the Gemfile exists. And complains that I have not committed the Gemfile.lock, which I don't want to commit.
-----> Heroku receiving push
-----> Ruby app detected
!
! Gemfile.lock is required. Please run "bundle install" locally
! and commit your Gemfile.lock.
!
! Heroku push rejected, failed to compile Ruby app
Is there a way to tell Heroku that the app is a Node app and not a Ruby app?
The solution to this, with a lot of help from Heroku Support is: use a build pack!
Override the Heroku default buildpacks by specifying a custom buildpack in the BUILDPACK_URL config var
$ heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs
You can also specify a buildpack during app creation
$ heroku create -s cedar --buildpack https://github.com/heroku/heroku-buildpack-nodejs
Simple when you know it. Some more documentation can be found at Heroku Dev Center
It seems there's a new way to do this as BUILDPACK_URL is now deprecated, explained here, but essentially the command is:
$ heroku buildpacks:set heroku/nodejs
You may also specify a buildpack during app creation:
$ heroku create myapp --buildpack heroku/nodejs
I haven't used Ruby. I don't know what gems are. But I know how to install them and do basic things like that.
I heard of Jekyll and decided to start my own using Heroku. I found Rack-Jekyll that will work on Heroku.
I created my site as per Jekyll instructions and it is running fine on my system. Then I did what I was told to do in http://github.com/bry4n/rack-jekyll#readme. But when I push it to Heroku, I get an error:
---> Heroku received push
---> Rack app detected
---> Installing rack-jekyll from http://rubygems.org
ERROR: could not find gem "rack-jekyll" locally or in a repository
On seeing this, I downloaded the rack-jekyll.gem file and committed it to the repsitory and tried uploading it. Even that didn't work. Can you tell me precisely what to do?
Updated (ht Andrew): use heroku's Bundler support
create a Gemfile like so
source "http://rubygems.org"
gem "rack-jekyll"