我想将 ruby​​ on rails 7.0.0.alpha 从 git 降级到 `6.1.3.2`

问题描述

...但它仍然使用 git 版本,虽然从 Gemfile 中删除,bundle exec 没有什么不同:

Using activestorage 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using mail 2.7.1
Using actionmailbox 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using actionmailer 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using actiontext 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using sprockets-rails 3.2.2
Using rails 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
/home/leder/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/runtime.rb:302:in `check_for_activated_spec!': You have already activated activesupport 6.1.3.2,but your Gemfile requires activesupport 7.0.0.alpha. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

更新: 我在 active_storage_main.rb 文件中降级了 rails gem,但现在我有一个不兼容的 sprockets 版本,它不在源代码中:

Installing sprockets 4.0.2 (was 3.7.2)
Using sprockets-rails 3.2.2
Using rails 6.1.3.2
/home/leder/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/runtime.rb:302:in `check_for_activated_spec!': You have already activated sprockets 3.7.2,but your Gemfile requires sprockets 4.0.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  #git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails",'~> 6.1.3','>= 6.1.3.2'
  #github: "rails/rails",branch: "main"
  gem "sqlite3"
end

require "active_record/railtie"
require "active_storage/engine"
require "tmpdir"

class TestApp < Rails::Application
  config.root = __dir__
  config.hosts << "example.org"
  config.eager_load = false
  config.session_store :cookie_store,key: "cookie_store_key"
  secrets.secret_key_base = "secret_key_base"

  config.logger = Logger.new($stdout)
  Rails.logger  = config.logger

  config.active_storage.service = :local
  config.active_storage.service_configurations = {
    local: {
      root: Dir.tmpdir,service: "Disk"
    }
  }
end

ENV["DATABASE_URL"] = "sqlite3::memory:"

Rails.application.initialize!

require ActiveStorage::Engine.root.join("db/migrate/20210523072040_create_active_storage_tables.active_storage.rb").to_s

ActiveRecord::Schema.define do
  CreateActiveStorageTables.new.change

  create_table :users,force: true
end

class User < ActiveRecord::Base
  has_one_attached :profile
end

require "minitest/autorun"

class BugTest < Minitest::Test
  def test_upload_and_download
    user = User.create!(
      profile: {
        content_type: "text/plain",filename: "dummy.txt",io: ::StringIO.new("dummy"),}
    )

    assert_equal "dummy",user.profile.download
  end
end

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...