bundler: failed to load command: jekyll (/usr/gem/bin/jekyll



我正在尝试将我的Jekyll网站部署到Codeberg Pages。我用的是一个叫啄木鸟的CI。我写了这个管道

pipeline:
publish:
image: jekyll/jekyll
secrets: [ codeberg_access_token ]
commands:
- bundle exec jekyll build
- cd _site
- git init
- git remote add up $CODEBERG_ACCESS_TOKEN@https://codeberg.org/mikwee/pages.git
- git push -u up master -f

遗憾的是,当CI运行它时,我得到了这个错误:

+ bundle exec jekyll build
bundler: failed to load command: jekyll (/usr/gem/bin/jekyll)
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/resolver.rb:271:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'github-pages' in locally installed gems. (Bundler::GemNotFound)
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/resolver.rb:254:in `map!'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/resolver.rb:254:in `verify_gemfile_dependencies_are_found!'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/resolver.rb:50:in `start'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/resolver.rb:24:in `resolve'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/definition.rb:270:in `resolve'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/definition.rb:473:in `materialize'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/definition.rb:191:in `specs'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/definition.rb:239:in `specs_for'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/runtime.rb:18:in `setup'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler.rb:162:in `setup'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/setup.rb:20:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/ui/shell.rb:136:in `with_level'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/ui/shell.rb:88:in `silence'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/setup.rb:20:in `<top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/cli/exec.rb:56:in `require_relative'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/cli/exec.rb:56:in `kernel_load'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/cli/exec.rb:23:in `run'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/cli.rb:483:in `exec'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/cli.rb:31:in `dispatch'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/cli.rb:25:in `start'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/exe/bundle:48:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.15/exe/bundle:36:in `<top (required)>'
from /usr/local/bin/bundle:25:in `load'
from /usr/local/bin/bundle:25:in `<main>'

为什么会发生这种情况?谢谢你。

在我的情况下,强制使用2.2.x版本的捆绑器,并使用bundle exec而不是直接使用gem相关命令,解决了问题。

此外,您可以确保使用的捆绑器版本与安装依赖项时使用的捆绑器版本相同。让我们检查Gemfile.lock文件的最后几行,例如:

...
BUNDLED WITH
2.2.14

相关内容

最新更新