Warm tip: This article is reproduced from stackoverflow.com, please click
heroku ruby-on-rails railtie

Heroku Deploy: URI::InvalidURIError: bad URI(is not URI?): ://user:pass@127.0.0.1/dbname

发布于 2020-04-11 22:32:45

I have a project with a Vue frontend and a rails backend. It's just a very simple API on the backend, no database or anything. It's working fine locally but now I want to deploy it on Heroku.

However, when I run it I get the following error.

-----> Detecting rake tasks
 !
 !     Could not detect rake tasks
 !     ensure you can run `$ bundle exec rake -P` against your app
 !     and using the production group of your Gemfile.
 !     rake aborted!
 !     URI::InvalidURIError: bad URI(is not URI?): ://user:pass@127.0.0.1/dbname
  ...
  ...
/activerecord-6.0.2.1/lib/active_record/railties/databases.rake

Based on various SO posts/Heroku documentation, I have already tried:

  • bundle exec rake -P RAILS_ENV=production - everything looks ok
  • adding the rake dependency in Gemfile
  • removing the sqlite dependency in Gemfile
  • removing the BUNDLED WITH from Gemfile.lock

But still the same error.

I guess it's related to my database config, but I don't have any database on my project so this seems like an unnecessary task anyway. I tried commenting out railties from my Gemfile but it's still there as a dependency for other gems. When I deploy after making this change, it still hits the same task and fails.

Link to repo branch

Questioner
Chris A
Viewed
134
Chris A 2020-02-03 22:39

Needed to fully remove use of ActiveRecord from the project. As Max commented, in a new app this can be done by doing rails new app_name --skip-active-record --api, to do this for an existing project see this explanation