Why is Heroku installing gems I don't use? - ruby-on-rails

I am trying to deploy our app to Heroku. It is a Rails 6/Ruby 2.6.5 app running against PostgreSQL.
For some reason Heroku installs the MySQL gem, and also it is failing trying install the Poppler gem dependencies (specifically gobject-introspection 3.4.1), even though we have removed Poppler from our Gemfile. The words Poppler and Mysql don't appear anywhere in our code.
I have done a bundle clean and saw those gems go.
Why is it doing this?

Related

How can I install Poppler on Heroku for my Rails app?

I wanted to enable previews on PDFs in Active Storage:
https://api.rubyonrails.org/classes/ActiveStorage/Preview.html
In order to do this I installed Poppler on my Mac using brew install poppler. I also installed the Poppler gem in my gemfile. The preview functionality works as I want on my local machine.
When I go to deploy to Heroku the build fails and I get the following error:
An error occurred while installing gobject-introspection (4.0.5), and Bundler
cannot continue.
In Gemfile:
poppler was resolved to 4.0.5, which depends on
gio2 was resolved to 4.0.5, which depends on
gobject-introspection
I've attempted using the following buildpack, but with no luck:
https://github.com/amitree/heroku-buildpack-poppler.git
Has anyone had any success installing Poppler on Heroku? Ideally on more recent Heroku stacks, and not an older stack.

Ruby on rails new app is not creating

I started to develop the new RoR web app and faced weird issue.
I wanted to create new app with Postgresql. So I installed the Postgres with brew and MacOS desktop app. And type rails new test-app --database=postgresql.
At this moment, I can't install bundles because there is certain
error.
An error occurred while installing pg (1.0.0), and Bundler cannot
continue.
Make sure that `gem install pg -v '1.0.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
run bundle exec spring binstub --all
Could not find gem 'pg (< 2.0, >= 0.18)' in any of the gem sources
listed in your Gemfile.
Run `bundle install` to install missing gems.
So I can't start new app.
Is this an issue that is occurring because of the mismatch between ruby and postgres version?
And how can I create new app with postgres?
I am currently using Mac OS high Sierra, postgres 10.5, rails 5.2.1
Try to skip running Bundler: rails new test-app --database=postgresql --skip-bundle
Once you've generated your app, you'll still have to troubleshoot why pg ins't installing. The PG gem should install just fine as long as the database is there and your system can build the gem's native extensions, so my first guess is either Postgres isn't installed or it can't be found in your environment.
Either way, this does answer your question. Skip the bundle and voila - Rails will generate a new clean app for you.
I've posted some comments, but i already seen that it seems to be an error when installing postgresql via brew. It's not common, but it happens sometimes.
Here's a quick fix:
brew install libpqxx
Make sure to run also
brew update
and restart your PostgreSQL server via:
brew services restart postgresql
Also make sure to clean up brew:
brew cleanup
If the error is still there, post your Gemfile and your database.yml file as well.
Greetings!

rails offline installation in windows

I want to install ruby on rails in offline mode (i.e. without internet connection). So I downloaded railsinstaller-3.2.0.exe from http://railsinstaller.org/en and installed it. By the end, I had ruby installed but in order to have rails installed I ran
gem install rails
and faced these errors: (meaning command needs internet connection)
ERROR: Loading command: install (ArgumentError)
unknown encoding name - CP720
ERROR: While executing gem ... (NoMethodError)
undefined method 'invoke_with_build_args' for nil:NilClass
I mean is there any solution like downloading gems with another computer connected to internet and then copying files in the proper location in the installed directory of gems.
Please help me if you have any idea.
As said in a comment, it's a gem (lib) dependency issue.
You might want to look into installing the bundler gem library to manage dependencies for you, with bundler you would just have to run, bundle install and it would download all the required gems for you including any gem dependencies.
You can install bundler simply, just run
gem install bundler
Then in your rails project directory, just run bundle install.
Often to run a project (like rails for example) you might have to start it with
bundle exec rails start
To install Gem's on a non-internet connect computer you might want to refer to this answer on just that problem.
This is the website where you can find all available ruby gems. Ruby
gems download. Find the one you are interested and download it.
Then move the gem in a directory of your choice and cd into that from
the command prompt. I am using C:/ruby193/bin/pony-1.4.gem
Let's say that the gem we are interested in is the pony gem (smtp
email).
Just type gem install pony-1.4.gem
and you should get it installed manually unless you have a restricted
acc with not adequate administrative privileges.
You can also refer to the official documentation on the matter.

Rails installation on hostmonster bundle install fails

So I had a rails app up and working on my hostmonster account just fine. I then updated a few things in my dev environment / pushed them up to github / pulled them back down on my production environment. Now its giving me the error Could not find pg-0.17.1 in any of the sources (Bundler::GemNotFound).
This is a new gem i installed in my dev because i was attempting to move to postgresql for dev and live....for now im using postgresql in dev and mysql2 in production. I know this isn't optimal but im working on it.
I tried running bundle install to get the pg gem installed and it fails with the error
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.2.2.gem] in /home4/muscorei/workspace/vollapp
An error occurred while installing rake (10.2.2), and Bundler cannot continue.
Make sure that gem install rake -v '10.2.2' succeeds before bundling.
I try installing rake and it works fine...try again..same error. I have found one question on here that seems to fix this for others but it requires running of gem update --system which you cannot do for hostmonster. Any ideas?
So here is another "related" issue. When i type in gem list --local I see that rails is installed at version 4.1.0....however when i do rails -v it shows the systemwide version of 3.2.13. I don't EVER have any of these annoying issues on my dev environment.

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.

Resources