2

我已将awesome_print添加到我的~/.irbrc文件中,如下所示:

require 'ap'

在 Rails 项目目录中,如果我运行irb它会很好地加载 gem,因为我已经在本地安装了 gem。但是如果我运行rails console,它会吐出这个错误:

cannot load such file -- ap

我该如何解决这个问题?我猜它正在应用程序的 Gemfile 中寻找 gem,但我不想将它添加到 Gemfile,因为我不希望其他开发人员需要该依赖项。我只想在我的机器上使用 awesome_print。

我也在使用 rbenv,如果这有帮助的话。

4

1 回答 1

2

There is this trick.

What you need to do is

# Copy the definition of the debundle! method into your ~/.irbrc
# Call 'debundle!' from IRB when you need to.

(as explained at the top of the file)

The text as it appears on the referred to site:


debundle.rb allows you to require gems that are not in your Gemfile when inspecting programs that are run with Bundler.

Use at your own risk!

Paste the code of debundle.rb and you are done! A good place would be your .irbrc file before requiring irbtools.

The code is directly taken from pry-debundle. Please look there for any further information. This repo exists to simplify debundling without using the pry repl.

于 2013-07-19T11:44:11.907 回答