Can't push rails code to Heroku from Cloud9 because of sqlite - ruby-on-rails

An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
remote: continue.
remote: Make sure that `gem install sqlite3 -v '1.3.10'` succeeds before bundling.
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Detected sqlite3 gem which is not supported on Heroku.
remote: ! https://devcenter.heroku.com/articles/sqlite3
remote: !
remote:
remote: ! Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to stark-reaches-8517.
remote:
To https://git.heroku.com/stark-reaches-8517.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com....
First I installed the latest sqlite3, but it didn't help. Then I tried to switch from sqlite to postgresql, but it didn't work out either (or I just missed something). Can somebody tell me how the gem file should look like before bundling? Btw. I am trying to follow Michael Hartl's Rails Tutorial, but it doesn't mention anything about this.
Added:
I have the rails_12factor and postgres gems in the production group. sqlite3 is in the development group so heroku should not attempt to install it.

When you used postgresql did you have add a Procfile to your app with this line:
web: bundle exec thin start -p $PORT
I use the following in my gem file, in addition to postgres to deploy to heroku
#User the 'thin' server instead of the default webrick
gem 'thin'
#Use postgres and the Heroku rails gem for Heroku
group :production do
gem 'rails_12factor'
end
Also, have you checked out the heroku help center? It jumps around a little bit, but goes into more detail about defing a Profile.
https://devcenter.heroku.com/articles/getting-started-with-ruby#introduction

Related

Can't start brand new rails app on Heroku

Trying to start up a brand new rails project with heroku, followed the steps in https://devcenter.heroku.com/articles/getting-started-with-rails5 and https://devcenter.heroku.com/articles/getting-started-with-rails6. Both times when I try to push to heroku master, I get
remote: -----> Detecting rake tasks
remote:
remote: !
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! /tmp/build_4403463c/config/boot.rb:5:in `require': cannot load such file -- bootsnap/setup (LoadError)
remote: ! from /tmp/build_4403463c/config/boot.rb:5:in `<top (required)>'
remote: ! from /tmp/build_4403463c/bin/rake:7:in `require_relative'
remote: ! from /tmp/build_4403463c/bin/rake:7:in `<main>'
remote: !
I've tried to surround the bootsnap/setup with a rescue, and it still hits this block.
In my case, I have 3 bundler versions installed:
gem list bundler
*** LOCAL GEMS ***
bundler (2.2.5, default: 2.1.4, 1.17.3)
Though 2.1.4 being the default, it seems it is not what being used when I bundle install.
I run bundle _2.1.4_ install and then it updates my Gemfile.lock.
# git diff
BUNDLED WITH
- 2.2.5
+ 2.1.4
Then the problem was gone when I git push heroku main. I found these links helpful in troubleshooting my issue: Heroku Rails build failing due to Bootsnap and Rake issues and How to switch bundler version?.
Found a solution, In Gemfile.lock I switched RUBY VERSION to ruby 2.6.6p146 and BUNDLED WITH to 1.17.3

Heroku uses older Ruby version when running `bundle install`

I'm trying to run a Rails app on Ruby 2.7.1 on Heroku. Everything worked fine, then I changed something in my Gemfile to use Ruby 2.7's numbered parameters, and now the deploy fails with this error message:
remote: -----> Build succeeded!
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.0.2
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote:
remote: !
remote: ! There was an error parsing your Gemfile, we cannot continue
remote: !
remote: ! [!] There was an error parsing `Gemfile`: Undefined local variable or method `_1' for Gemfile. Bundler cannot continue.
remote: !
remote: ! # from /tmp/build_6681cf5c/Gemfile:22
remote: ! # -------------------------------------------
remote: ! # dependencies.any? { _1.name == gem_name }
remote: ! # -------------------------------------------
remote: ! . Bundler cannot continue.
It works fine locally and I've been using the same code in a few other Rails apps and deployment was never a problem.
Due to the error Undefined local variable or method '_1' for Gemfile. I assume a Ruby version < 2.7 is used when running bundle install.
The app itself runs fine on Ruby 2.7.1 though:
$ heroku run "ruby -v"
Running ruby -v on ⬢ myapp... up, run.7979 (Free)
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
There are a few other similar questions here on SO, but they all deal with Heroku not respecting the Ruby version set in Gemfile or .ruby-version, which is not the problem for me, just during bundle install it seems to use a different Ruby version for some reason...
Is there any way to debug this further, or force Ruby 2.7 even during bundle install on deployment?

Heroku Rails deployment/build error: Could not find 'bundler' (version) required by your Gemfile.lock

I have a Ruby on Rails and Redux/React app I have already pushed dozens of times to heroku via "git push heroku master" and it builds correctly. I recently tried to create a staging environment. After setting the remote, I run
git push staging master
And the webpack portion builds correctly, but once Heroku tries to build the Rails portion I get this error.
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! Activating bundler (2.0.1) failed:
remote: ! Could not find 'bundler' (2.0.1) required by your /tmp/build_687b8b1cf6d6cbb297288640ccb0d405/Gemfile.lock.
remote: ! To update to the latest version installed on your system, run `bundle update --bundler`.
remote: ! To install the missing version, run `gem install bundler:2.0.1`
remote: ! Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote: !
remote: ! To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
To create the staging environment, I ran
heroku create --remote staging
in the root folder of the project.
I also have tried updating the bundler.
bundle update --bundler
&
gem install bundler:2.0.1
I tried precompiling assets as well, but nothing.
RAILS_ENV=production bundle exec rake assets:precompile
I ran
bundle exec rake -P
as suggested, but that did not fix it as well.
Another thing is when I push successfully, in the logs it shows I am using a different ruby version
Using Ruby version: ruby-2.3.4
remote: -----> Installing dependencies using bundler 2.0.2
In the staging logs it shows
Using Ruby version: ruby-2.5.5
remote: -----> Installing dependencies using bundler 2.0.2
Not sure if that helps. But any possible solutions can help!
Thanks!
The solution to issues like these it to ensure all environments (development, staging, production, CI) share the same Ruby version. This will make development and testing much more predictable.
Specify your Ruby version in the Gemfile (this build worked with Ruby 2.3.4, so that's what we'll use):
# Gemfile
ruby '2.3.4'

"Push rejected, failed to compile Ruby app" installation of decdim on herouku

I'm trying to install decidim (decidim.org) on herouku, I get this error when i make the deploy
remote: You are trying to install in deployment mode after changing
remote: your Gemfile. Run bundle install elsewhere and add the
remote: updated Gemfile.lock to version control.
remote:
remote: The gemspecs for path gems changed
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
this is the end lines of the deploy.
anyone has an answer for this issue?
thanks
Go to the folder where you have your app and try typing the command: bundle install then try pushing to heroku afterwards.

ruby_dep installation error

I'm following the Hartl rails tutorial, figured I'd give ruby a go. Previously was able to deploy to heroku just fine. Started a new project, and right after I changed my gem file and used the "bundle update" command, I got this error message:
An error occurred while installing ruby_dep (1.2.0), and Bundler cannot continue.
I tried pushing to my heroku master branch and got this message:
remote: ! Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy....
remote:
! [remote rejected] master -> master (pre-receive hook declined)
I updated my bundler, my version of ruby is up to date...no clue what's going on here. Any help?
You must either have ruby >= 2.2.5 or add the following gem to your gemfile
gem 'listen', '3.1.1' and then run
bundle install
Since I have ruby 2.2.4, I added the above gem to my gemfile , then ran bundle install
Everything works fine after this step. Enjoy.

Resources