突然"已初始化常数"运行rake任务时出错

时间:2018-06-11 23:14:04

标签: ruby-on-rails ruby initialization rake rake-task

我一直在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

我找到了一些相关的主题,说我的问题是我需要键入"捆绑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 个答案:

答案 0 :(得分:0)

出于某种原因,我的服务器对我的Ruby文件夹的外壳感到困惑,似乎认为有两个,虽然没有。我不得不在我的应用程序本地重新安装所有内容而不是全局,如下所示:

bundle install --path vendor/cache

现在没有任何警告。