代码之家  ›  专栏  ›  技术社区  ›  Joe Morano

运行rake任务时突然出现“已初始化常量”错误

  •  0
  • Joe Morano  · 技术社区  · 7 年前

    我在Windows机器上运行rake任务一段时间没问题。然后,当我运行与rake相关的任何东西时,我突然开始出错。这是我跑后第一次发生 rake db:migrate 我认为这可能是在我改变了一个迁移之后,没有先回滚它。现在,每个rake命令都会给出:

    > rake db:rollback
    
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_utils.rb:10: warning: already initialized constant FileUtils::RUBY
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_utils.rb:10: warning: previous definition of RUBY was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_utils.rb:109: warning: already initialized constant FileUtils::LN_SUPPORTED
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_utils.rb:109: warning: previous definition of LN_SUPPORTED was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_utils_ext.rb:17: warning: already initialized constant Rake::FileUtilsExt::DEFAULT
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_utils_ext.rb:17: warning: previous definition of DEFAULT was here
    WARNING: Possible conflict with Rake extension: String#ext already exists
    WARNING: Possible conflict with Rake extension: String#pathmap already exists
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:44: warning: already initialized constant Rake::FileList::ARRAY_METHODS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:44: warning: previous definition of ARRAY_METHODS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:47: warning: already initialized constant Rake::FileList::MUST_DEFINE
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:47: warning: previous definition of MUST_DEFINE was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:51: warning: already initialized constant Rake::FileList::MUST_NOT_DEFINE
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:51: warning: previous definition of MUST_NOT_DEFINE was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:55: warning: already initialized constant Rake::FileList::SPECIAL_RETURN
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:55: warning: previous definition of SPECIAL_RETURN was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:61: warning: already initialized constant Rake::FileList::DELEGATING_METHODS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:61: warning: previous definition of DELEGATING_METHODS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:86: warning: already initialized constant Rake::FileList::GLOB_PATTERN
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:86: warning: previous definition of GLOB_PATTERN was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:381: warning: already initialized constant Rake::FileList::DEFAULT_IGNORE_PATTERNS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:381: warning: previous definition of DEFAULT_IGNORE_PATTERNS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:387: warning: already initialized constant Rake::FileList::DEFAULT_IGNORE_PROCS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/file_list.rb:387: warning: previous definition of DEFAULT_IGNORE_PROCS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:3: warning: already initialized constant Rake::VERSION
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:3: warning: previous definition of VERSION was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::MAJOR
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of MAJOR was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::MINOR
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of MINOR was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::BUILD
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of BUILD was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::OTHER
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of OTHER was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:8: warning: already initialized constant Rake::Version::NUMBERS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/version.rb:8: warning: previous definition of NUMBERS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/linked_list.rb:110: warning: already initialized constant Rake::LinkedList::EMPTY
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/linked_list.rb:110: warning: previous definition of EMPTY was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/scope.rb:41: warning: already initialized constant Rake::Scope::EMPTY
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/scope.rb:41: warning: previous definition of EMPTY was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/promise.rb:12: warning: already initialized constant Rake::Promise::NOT_SET
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/promise.rb:12: warning: previous definition of NOT_SET was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/application.rb:13: warning: already initialized constant Rake::CommandLineOptionError
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/application.rb:13: warning: previous definition of CommandLineOptionError was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/application.rb:41: warning: already initialized constant Rake::Application::DEFAULT_RAKEFILES
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/application.rb:41: warning: previous definition of DEFAULT_RAKEFILES was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/task_arguments.rb:108: warning: already initialized constant Rake::EMPTY_TASK_ARGS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/task_arguments.rb:108: warning: previous definition of EMPTY_TASK_ARGS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/invocation_chain.rb:55: warning: already initialized constant Rake::InvocationChain::EMPTY
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/invocation_chain.rb:55: warning: previous definition of EMPTY was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/early_time.rb:21: warning: already initialized constant Rake::EARLY
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/early_time.rb:21: warning: previous definition of EARLY was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/late_time.rb:17: warning: already initialized constant Rake::LATE
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/late_time.rb:17: warning: previous definition of LATE was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:4: warning: already initialized constant Rake::Backtrace::SYS_KEYS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:4: warning: previous definition of SYS_KEYS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:5: warning: already initialized constant Rake::Backtrace::SYS_PATHS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:5: warning: previous definition of SYS_PATHS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:8: warning: already initialized constant Rake::Backtrace::SUPPRESSED_PATHS
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:8: warning: previous definition of SUPPRESSED_PATHS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:12: warning: already initialized constant Rake::Backtrace::SUPPRESSED_PATHS_RE
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:12: warning: previous definition of SUPPRESSED_PATHS_RE was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:16: warning: already initialized constant Rake::Backtrace::SUPPRESS_PATTERN
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake/backtrace.rb:16: warning: previous definition of SUPPRESS_PATTERN was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake.rb:70: warning: already initialized constant FileList
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake.rb:70: warning: previous definition of FileList was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake.rb:71: warning: already initialized constant RakeFileUtils
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.0/lib/rake.rb:71: warning: previous definition of RakeFileUtils was here
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/load_error.rb:2: warning: already initialized constant LoadError::REGEXPS
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/load_error.rb:2: warning: previous definition of REGEXPS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/validations/clusivity.rb:6: warning: already initialized constant ActiveModel::Validations::Clusivity::ERROR_MESSAGE
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/validations/clusivity.rb:6: warning: previous definition of ERROR_MESSAGE was here
    

    我发现一些相关的线程说问题在于我需要在命令前键入“bundle exec”。我以前从来没有这样做过,但我尝试过。我有一个较短但相似的错误:

    > bundle exec rake db:rollback
    
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/load_error.rb:2: warning: already initialized constant LoadError::REGEXPS
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/load_error.rb:2: warning: previous definition of REGEXPS was here
    c:/ruby24-x64/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/validations/clusivity.rb:6: warning: already initialized constant ActiveModel::Validations::Clusivity::ERROR_MESSAGE
    c:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/validations/clusivity.rb:6: warning: previous definition of ERROR_MESSAGE was here
    

    有人知道是什么引起的吗?


    更新

    出于某种原因,我的计算机对Ruby的位置感到困惑,所以我必须在本地重新安装所有东西,而不是像这样在全球重新安装:

    bundle install --path vendor/cache
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Joe Morano    7 年前

    出于某种原因,我的服务器对我的Ruby文件夹的大小写感到困惑,似乎认为有两个,尽管没有。我必须在本地而不是全局重新安装应用程序中的所有内容,如:

    bundle install --path vendor/cache
    

    而且它现在没有任何警告。