Heroku rails pg_ext.so LoadError - ruby-on-rails

I am trying to deploy my rails app to Heroku. I've created an app and successfully pushed it, but when i do
heroku run rake db:migrate
i am getting this error
> rake aborted!
> LoadError: libruby.so.2.3: cannot open shared object file: No such file or directory -
> /app/vendor/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg_ext.so
Rails 5.0.4
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
pg-0.21.0
I've seen similar posts and tried to apply described solutions, but no luck. Tried other versions of pg like here Cannot migrate on Heroku
But it didn't help.
Thanks.

Try purging Heroku dyno's cache:
heroku plugins:install https://github.com/heroku/heroku-repo.git
heroku repo:purge_cache -a appname

Related

Error when trying precompile assets, getting yarn error with rails

rails -v: Rails 6.1.0
ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]
I'm having this error when I try to run rails assets:precompile
rails aborted!
Errno::ENOEXEC: Exec format error - C:/Users/trynot/Desktop/prolife/bin/yarn --version
Tasks: TOP => assets:precompile => yarn:install
(See full trace by running task with --trace)
What I've tried:
I already uninstalled and reinstalled all my gems, tried to update all my gems, tried to generate a new project with the flags --skip-webpack-install, tried removing the file yarn from bin, and tried to reinstall yarn. Same problem!
This issue is resolved on this commit https://github.com/rails/rails/commit/5c8805034f5f59b7278f895fca7b6fd7dfda7af5#diff-7c64b5585b553fe2873f6b3cee2675a6d63997f3c7af82ccf23c1073773c40d3

Rails Heroku pg_ext.so

I'm trying to deploy my Rails app with Heroku. The app works fine in a local environment, and git push heroku master works fine, but an application error page is displayed when I try to view the deployed app. I'm getting similar errors from the logs and whenever I try to run a heroku run rake db:migrate command:
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg.rb:4:in `require': libruby.so.2.3: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg_ext.so (LoadError)
Windows 10 Bash with Ubuntu
Ruby 2.3.4p301
Rails 5.0.3
PostgreSQL 9.3.16
pg Gem 0.21.0
I've checked multiple posts that had the same error, but none of them helped.

Deploying Ruby on Rails to Heroku

I am trying to upload RoR application to Heroku.
OS - Ubuntu, ruby version - 2.2.2p95, rails version - 4.2.1, database - PostgreSQL, installed RoR via BrightBox (Tutorial from treehouse), using git push heroku master to upload.
On the local server app works fine. When I push it to heroku, it gives out an error:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
Log files say:
/usr/bin/env: ruby2.2: No such file or directory
I've tried all the possible variants, I could find on the Internet:
rake rails:update:bin
Remove bin from ~/.gitignore (But there is no such file)
heroku config:set PATH=bin:vendor/bundle/ruby/2.2.2/bin:/usr/local/bin:/usr/bin:/bin
Adding this to the GemFile: ruby '2.2.2'
Changed #!/usr/bin/env ruby2.2(.2 (not sure about ".2")) to #!/usr/bin/env ruby (in bin/rake, bin/bundle and bin/rails)
heroku run rails db:migrate
rake rails:update:bin
ln -s /usr/bin/nodejs /usr/bin/node
To upload to heroku, I've configured git, after that logged in heroku, after that "heroku create", after that "git push heroku master", then "heroku open"
And many others... Any ideas how to solve that problem?
Do you have the gem rails12_factor installed and config.assets.compile = true ?
Not sure you mistyped or something else. but heroku run rails db:migrate will not work it should be heroku run rake db:migrate . It might be because you don't have root page. Precompile issue etc.
Run heroku logs -a app_name to see actual logs.

Heroku Cedar rake version

What version of Rake does Heroku Cedar use?
My gemfile is at version 10.0.2 which the deployment code confirms is bundling on Heroku:
Installing rake (10.0.2)
But the app won't start, and running heroku run rake db:migrate --app appname or looking at the heroku logs --tail gives me /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake.rb:24:in 'require': no such file to load -- rake/version (LoadError)
rake is not pre-installed on Cedar, you just have an empty container. All the dependencies are brought in from your application (e.g Bundler).

Tutorial demo_app won't work on heroku

I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.
I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.
What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)
I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)
I'm new to ruby and rails so I'm at a loss. Any ideas?
Solved below.
Yes , this worked for me too after installing the pg gem, I ran the following:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
after invoking these commands, I was able to successfully open the demo_app on heroku.
Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:
Install pg gem to use postgreSQL on Heroku: (related article)
sudo gem install pg
Install taps gem to allow push of your local database to Heroku: (related article)
gem install taps
then the following sequence…
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar
The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.

Resources