【发布时间】:2018-06-11 23:14:04
【问题描述】:
我在 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
【问题讨论】:
-
这个错误与上一个错误相似如何?
bundle exec是确保使用本地 gemset 所必需的。后一条错误消息清楚地说明了如何解决问题。 -
@mudasobwa 宝石错误是一个单独的问题,已经出现了一段时间。我应该从我的问题中删除这些行,但无论如何我现在添加了 gem 并更新了我得到的错误输出。
-
Windows 的文件系统(仍然是 NTFS 吗?)是否区分大小写?我想知道您的日志中
Ruby24-x64与ruby24-x64是什么意思。如果是,您可能需要删除其中一个。 -
@mudasobwa 奇怪,我不确定它为什么写成“ruby24-x64”。我的电脑上只有
Ruby24-x64。 -
@mudasobwa 是的,这似乎是问题所在。我在本地而不是全局重新安装了所有内容并修复了它。
标签: ruby-on-rails ruby initialization rake rake-task