Heroku gem shows up despite having heroku toolbelt - ruby-on-rails

in my project folder, when I run heroku version, I get heroku-gem/3.32.0 (x86_64-linux) ruby/2.2.0 as one of the items, however in my home folder running the same command returns heroku-toolbelt/3.42.50 (x86_64-linux) ruby/2.2.0. How can I use heroku toolbelt in my project folder?

Solution would be to uninstall the heroku gem like : gem uninstall heroku
and Upgrade Heroku Toolbelt.

Related

heroku run rake db:migrate fails to deploy

I'm trying to deploy my Rails6 app to Heroku
I'm able to successfully build after pushing my app to Heroku but the app immediately crashes.
I just added
group :production do
gem 'pg', '~> 1.2', '>= 1.2.3'
end
to my Gemfile after developing in sqlite so I figured I'd need to migrate which brings me to my error
peter.walker#MACSB-RJ2CLKF45C friends % heroku run rake db:migrate
Running rake db:migrate on ⬢ ptw-friends... up, run.5761 (Free)
Your Ruby version is 2.7.0, but your Gemfile specified 2.6.10
I'm not sure why I'm being told my Ruby version is 2.7.0.
My Gemfile has ruby '2.6.10',
my Gemfile.lock has RUBY VERSION ruby 2.6.10p210,
and my $ ruby -v returns ruby 2.6.10p210 (2022-04-12 revision 67958) [arm64-darwin21]
Could it be from adding
"scripts": {
"start": "rails s"
},
to my package.json?
Could I not be specifying the Ruby version in Procfile?
The full error is here along with my repo
https://github.com/petertimwalker/friends/issues/1
Heroku doesn't support all Ruby versions. When a Ruby version reaches end-of-life and is not maintained anymore then Heroku stops supporting it.
Ruby 2.6 reached end-of-life December last year.
Therefore you need to update your application and your local environment to at least 2.7 when you still want to be able to deploy on Heroku.
Please see the list of Ruby versions supported by Heroku.
install ruby version 2.6.10 and use that version in local
if you using rvm check your current version with rvm list and
install ruby 2.6.10 with rvm install 2.6.10
then use command rvm use 2.6.10

Rails 3.2 not using bundled gems, Capistrano needs sudo gem install and rbenv not finding rails

I have 2 Rails 3.2.11 apps running on an Ubuntu 12.04 server with Nginx, Unicorn and Postgresql. Deployment is by git and capistrano.
After I installed the second app I found that Capistrano would fail during cap deploy because it "could not find a gem source" and I needed to install each missing gem using sudo. After this, cap deploy worked fine and so did the apps. Running bundle install from the current dir in either app reported using all the correct gems.
I am perplexed that Capistrano needs to find the gems before updating my app as my past experience (I think) was that I could run bundle install from the current dir to install any new or updated gems after cap deploy.
Today, I decided to update my Ruby version using rbenv on my dev laptop. I needed to run git pull from .rbenv/plugins/ruby-build and then rbenv rehash then I could install the new Ruby version. All good, ruby-v reports the new version 19.3-p374.
Now, when I run rails server (rails s) from my app dev dir I get rbenv: rails: command not found. The rails' command exists in these Ruby versions: 1.9.3-p327. rbenv version reports
1.9.3-p374. Rbenv which rails and bundle install both report "command not found: with rbenv error "Therails' command exists in these Ruby versions: 1.9.3-p327".
So, two issues which I believe are related:-
How to make each app on my server independently run its own gems using bundle install? I don't want to freeze the gems and am quite happy to keep both apps up to date simultaneously. Should I just keep installing the required gems using sudo?
How to fix the rbenv issue of not finding rails in the new version?
I needed to reinstall all gems again. Gem install bundler and then bundle update from each application directory.

Deploying rails app on heroku

I'm learning RoR and trying to deploy my test app to heroku receiving next error:
Unresolved dependencies detected; Installing...
Using --without developmen
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
You have added to the Gemfile:
* therubyracer (~> 0.9.3.beta1)
* pg
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
Please! Help!
Have you committed your Gemfile.lock?
bundle install
git add Gemfile.lock
git commit -am "Add lock file"
git push heroku master
This error might be because you did not completely do bundle install.
First do
bundle install
Add gem 'pg' to the gem file and install the postgres gems and postgres on your local machine. If you dont want to install postgres on your local machine then add gem 'pg to production environment and run bundle install without test environment. Though heroku discourages this way of running your application. It is always better to use same database for running locally and in production. Installing postgres is pain but it is worth it.
Your ruby should be 1.9.2.
After installing all the dependencies and post gres on your machine do bundle install and add your gem file to heroku.
git add Gemfile
git add Gemfile.lock
git commit
git push heroku master

Trouble pushing barebones app to Heroku with paperclip gem

We have an app that's been running on Heroku (bamboo) for over a year. When pushing a change yesterday, the push was rejected when it failed to install the paperclip gem. No changes had been made to the gem list up to the point of failure. I tried a brand new, barebones app and got the same result. It seems the bamboo stack has changed in some way. Anybody else experiencing this or know what might be going on?
Here are repro steps:
$ rails temp-app
$ cd temp-app
$ cat >.gems
rails -v 2.3.14
paperclip -v 2.5.0
<control-D>
$ git init
$ git add .
$ git commit -m "init"
$ heroku create --stack bamboo
$ git push heroku master
this is the output:
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Installing gem rails 2.3.14 from http://rubygems.org
Successfully installed activesupport-2.3.14
Successfully installed activerecord-2.3.14
Successfully installed actionpack-2.3.14
Successfully installed actionmailer-2.3.14
Successfully installed activeresource-2.3.14
Successfully installed rails-2.3.14
6 gems installed
-----> Installing gem paperclip 2.5.0 from http://rubygems.org
ERROR: While executing gem ... (NoMethodError)
undefined method `call' for nil:NilClass
! Heroku push rejected, failed to install gem
I did get an answer from Heroku support: Paperclip specifies a dependency on Active Record like this: 'activerecord', '>= 2.3.0' which causes the latest AR version to be installed. The latest version as of a few days ago is 3.2, which is broken on Rails 2.3, hence the failure.
I solved this by adding --ignore-dependencies to the paperclip gem in .gems and manually adding dependencies to .gems.

How do I install forked gems on heroku?

I'm trying to get Heroku working with European buckets on amazon s3 webserivces using the aws-s3 gem. It seems I need to install a forked version of the gem to get around the issue. However, with heroku I can only use the .gems file to install gems.
Can I use this .gems file to install forked-gems somehow?
Unpack the gem in your local repository, then add it to your git repository. This will copy the gem to your vendor/gems directory. Also remember to remove the gem from your .gems list to prevent Heroku from using the unwanted version.
#Unpacks all gems
rake gems:unpack
#Unpack a specific gem
rake gems:unpack GEM=xxxxx
Heroku already supports Bundler even for not-Rails 3 application.
http://blog.heroku.com/archives/2010/2/17/gem_bundler_on_heroku/
You can switch to Bundler and use its syntax to have Bundler downloading the Gem from the fork.

Resources