ruby - cannot load such file -- bundle/bundler/setup (LoadError)

【字号: 日期:2022-10-17浏览:31作者:雯心

问题描述

初学 ruby,尝试使用 zhaocai/alfred2-ruby-template 写 Alfred Workflow 时遇到以下错误:

bash$ ruby main.rb /Users/tranch/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’: cannot load such file -- bundle/bundler/setup (LoadError) from /Users/tranch/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’ from main.rb:5:in `<main>’

Google 了下相关关键词,都说因为没装 bundler,但是反复验证了一番,证明确实是都安装了:

bash$ which gem/Users/tranch/.rvm/rubies/ruby-2.2.0/bin/gemmaster*$ gem list -d bundler*** LOCAL GEMS ***bundler (1.10.3) Authors: André Arko, Terence Lee, Carl Lerche, Yehuda Katz Homepage: http://bundler.io License: MIT Installed at: /Users/tranch/.rvm/gems/ruby-2.2.0 The best way to manage your application’s dependenciesbundler-unload (1.0.2) Author: Michal Papis Homepage: https://github.com/mpapis/bundler-unload License: Apache 2.0 Installed at: /Users/tranch/.rvm/gems/ruby-2.2.0@global Allow unloading bundler after Bundler.loadrubygems-bundler (1.4.4) Authors: Josh Hull, Michal Papis Homepage: http://mpapis.github.com/rubygems-bundler License: Apache-2.0 Installed at: /Users/tranch/.rvm/gems/ruby-2.2.0@global Stop using bundle exec$ which bundle/Users/tranch/.rvm/gems/ruby-2.2.0/bin/bundle$ bundleUsing fuzzy_match 2.1.0Using builder 3.2.2Using gyoku 1.3.1Using moneta 0.8.0Using nori 2.6.0Using plist 3.1.0Using terminal-notifier 1.6.3Using alfred-workflow 2.0.5Using bundler 1.10.3Bundle complete! 2 Gemfile dependencies, 9 gems now installed.Bundled gems are installed into ./bundle.

求解。

问题解答

回答1:

应该是引用 require ’bundler/setup’ 试试看, 参考 http://bundler.io/bundler_setup.html

相关文章: