安装了Bundler 2.0.2和Jekyll / Gulp,仍然收到“必须使用Bundler 2或更高版本”消息

时间:2019-10-09 14:36:41

标签: javascript ruby gulp jekyll bundler

我遇到了我的Jekyll / Gulp设置失败的问题,即使安装了Bundler 2.0.2,我仍然收到的消息是“必须使用Bundler 2或更高版本”。还有其他类似问题,但这些项目是基于Rails和Heroku的。到目前为止,我发现的所有解决方案都对我不起作用。

终端显示我安装的Bundler版本与Gemfile.lock中列出的版本相同。

import os
import pandas as pd 
path = 'C:/PanelComplete/FileForPeter/'
for folder in os.listdir(path):
for file in os.listdir(path+folder):
    df = pd.read_csv(path+folder+'/'+file,engine='python')
    df1 = df.groupby('codprg').size().reset_index(name='counts')
    df1.to_csv(spath1+folder+'.csv', index=False,encoding='utf-8')

我正在运行Ruby 2.6.5:

fs-217-156:jekyll-gulp mrjandre$ bundler -v
Bundler version 2.0.2

来自Gemfile.lock:

fs-217-156:jekyll-gulp mrjandre$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin17]

在过去的几天里,我尝试卸载并重新安装Bundler和Jekyll至少十二次。

PLATFORMS
  ruby
  x64-mingw32

DEPENDENCIES
  jekyll (~> 3.8.5)
  jekyll-feed (~> 0.6)
  tzinfo-data

BUNDLED WITH
   2.0.2
gem uninstall bundler
gem install bundler -v '2.0.2'
gem update --system

不知道bundle update --bundler 是什么,但我也尝试了一下:

binstubs

运行“ gulp”的结果:

bundle binstubs bundler

这是fs-217-156:jekyll-gulp mrjandre$ gulp [09:48:24] Using gulpfile ~/Desktop/Repos/jekyll-gulp/gulpfile.js [09:48:24] Starting 'default'... [09:48:24] Starting 'styles'... [09:48:25] Finished 'styles' after 928 ms [09:48:25] Starting 'scripts'... [09:48:27] Finished 'scripts' after 1.35 s [09:48:27] Starting 'images'... [09:48:27] Finished 'images' after 3.84 ms [09:48:27] Starting 'jekyll-build'... Traceback (most recent call last): 13: from /usr/local/bin/jekyll:22:in `<main>' 12: from /usr/local/bin/jekyll:22:in `load' 11: from /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/exe/jekyll:11:in `<top (required)>' 10: from /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/plugin_manager.rb:52:in `require_from_bundler' 9: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler.rb:101:in `setup' 8: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler.rb:135:in `definition' 7: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:34:in `build' 6: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/dsl.rb:13:in `evaluate' 5: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/dsl.rb:234:in `to_definition' 4: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/dsl.rb:234:in `new' 3: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:83:in `initialize' 2: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:83:in `new' 1: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize' /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError) [09:48:27] 'jekyll-build' errored after 612 ms [09:48:27] Error: exited with error code: 1 at ChildProcess.onexit (/Users/mrjandre/Desktop/Repos/jekyll-gulp/node_modules/end-of-stream/index.js:39:36) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) [09:48:27] 'default' errored after 2.9 s 中的jekyll-build任务,非常标准:

gulpfile.js

我还删除了gulp.task("jekyll-build", function () { return cp.spawn( jekyll , ["build"], {stdio: "inherit"}) }); 并重新安装了这些依赖项几次,运行了node_modules并更新了npm。

我经常在Mac OSX和Windows 10之间切换,这种设置多年来在两个系统上都是可靠的。任何指示和建议将不胜感激,如果我错过了什么,我很乐意提供其他信息。

1 个答案:

答案 0 :(得分:0)

编辑:Homebrew misconfiguration issue已于2019-10-30修复。

如果您按照Jekyll on macOS instructions安装了Jekyll,则可以通过Homebrew获得Ruby 2.6.5,那么根本的问题是Homebrew(直到2019-10-30)配置不正确的RubyGems使得或多或少不可能获得Ruby加载Ruby's default gems中任何一个的较新版本,例如result = [] for item in data_source.get_next_obj(): result.append(json.dumps(item)) msg.set(result)

错误的配置是覆盖RubyGems customization point bundler中的default_dir,显然是试图将“标准” gem安装文件夹移至/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/defaults/operating_system.rb

但是,/usr/local/lib/ruby/gems/2.6.0 需要指向default_dir,因为它包含具有默认gem规格的/usr/local/Cellar/ruby/2.6.5/lib/ruby/gems/2.6.0文件夹。 如果无法从specifications/default加载默认宝石,则RubyGems覆盖Gem::Specification::default_specifications_dir不会激活默认宝石的较新版本,即使已安装并找到它们也是如此,这会阻止加载捆绑程序2.0.2。诸如Jekyll之类的非默认宝石仍会按预期加载。

由于Homebrew RubyGems配置错误,导致的问题是路径中的require命令将是用户安装的v2.0.2,因为您做了bundler并添加了用户安装路径({ {1}})添加到$ PATH中,而gem install --user-install bundler jekyll命令仅由于配置错误而仅看到并使用默认的bundler gem v1.17.2-这些版本不匹配会导致您遇到问题。

等待Homebrew修复Ruby公式,可以通过将其替换为以下内容来修复operating_system.rb中的错误配置。

$HOME/.gem/ruby/2.6.0/bin

(假设您没有将HOMEBREW_PREFIX更改为/ usr / local)

另请参阅与此相关的Homebrew issuethis answer