代码之家  ›  专栏  ›  技术社区  ›  Chris A

Heroku Deploy:URI::InvalidURIError:错误的URI(不是URI?): ://用户:pass@127.0.0.1/dbname

  •  0
  • Chris A  · 技术社区  · 5 年前

    但是,当我运行它时,我得到以下错误。

    -----> 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
    

    根据各种SO posts/Heroku文档,我已经尝试过:

    • bundle exec rake -P RAILS_ENV=production -一切看起来都很好
    • 添加 rake Gemfile中的依赖关系
    • sqlite
    • 从中移除捆绑的Gemfile.lock文件

    我想这与我的数据库配置有关,但我的项目中没有任何数据库,所以这似乎是一个不必要的任务。我试着从Gemfile中注释掉railties,但它仍然作为其他gem的依赖项存在。当我在进行此更改后进行部署时,它仍然执行相同的任务并失败。

    链接到 repo branch

    0 回复  |  直到 5 年前
        1
  •  0
  •   max Mike Williams    5 年前

    而不是 require 'rails/all'

    require File.expand_path('../boot', __FILE__)
    
    # Require the gems listed in Gemfile, including any gems
    # you've limited to :test, :development, or :production.
    Bundler.require(*Rails.groups)
    
    require "rails"
    # Pick the frameworks you want:
    require "active_model/railtie"
    require "active_job/railtie"
    # require "active_record/railtie"
    # require "active_storage/engine"
    require "action_controller/railtie"
    require "action_mailer/railtie"
    require "action_mailbox/engine"
    # require "action_text/engine"
    require "action_view/railtie"
    require "action_cable/engine"
    require "sprockets/railtie"
    
    module Draw
      class Application < Rails::Application
        # You don't need this nonsense since you don't even have config/application.yml
        #  ENV.update YAML.load_file('config/application.yml')[Rails.env] rescue {}
        # Settings in config/environments/* take precedence over those specified here.
        # Application configuration should go into files in config/initializers
        # -- all .rb files in that directory are automatically loaded.
    
        # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
        # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
        # config.time_zone = 'Central Time (US & Canada)'
    
        # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
        # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
        # config.i18n.default_locale = :de
    
        # Do not swallow errors in after_commit/after_rollback callbacks.
        # config.active_record.raise_in_transactional_callbacks = true
      end
    end
    

    如果你不想使用ActiveRecord,你可以去掉它 /db /config/database.yml .

    gem 'rake' 在你的Gemfile中,rails依赖于它。

        2
  •  0
  •   Chris A    5 年前

    Max commented ,在新的应用程序中,可以通过 rails new app_name --skip-active-record --api this explanation