如何使用捆绑器重新安装宝石 [英] How to reinstall a gem using bundler
问题描述
我做了一个 bundle show
并获得了一个gem目录的完整路径。
不幸的是,我删除了该目录使用 rm -r gem_path
。然后我的导轨应用程序不再工作了。如果我尝试启动服务器或启动rails控制台,它会输出以下错误:
< class:Application>
:未初始化的常量MyAPP :: Application :: Gem
(NameError)
我应该做些什么来恢复它?
我试过 bundle install
或 bundle update
,希望强制该包搜索该宝石并将其重新安装,但无效。
我也尝试删除 Gemfile.lock
并运行 bundle install
。没有任何变化,同样的错误。
有问题的宝石是 标记为 。
首先,我做了一个 gem q --L
, gem query --local
的快捷键。它为我输出安装的所有本地gem。
actionmailer(3.2.8,3.2.6,3.2.1,3.1。 0)
$ p
actionpack(3.2.8,3.2.6,3.2.1,3.1.0)
activemodel(3.2.8,3.2.6,3.2.1,3.1.0)
activerecord(3.2.8,3.2.6,3.2.1,3.1.0)
activeresource(3.2.8,3.2.6,3.2.1,3.1.0)
activesupport(3.2.8, (2.3.3)
...
act-as-taggable-on $ p>
然后,按照DVG的建议,我使用正确的名称卸载了gem
gem uninstall acts-as-taggable-on
并运行bundle install
。之后,我再次可以rails c
或rails s
。I did a
bundle show
and get the complete path to a gem directory.Unfortunately, I removed the directory using
rm -r gem_path
. Then my rails app isn't working anymore. If I try start server or start rails console it outputs the following error:
<class:Application>
: uninitialized constantMyAPP::Application::Gem
(NameError)What should I do to have it back?
I tried
bundle install
orbundle update
in hope of forcing the bundle to search the gem and install it back, but didn't work.I also tried delete the
Gemfile.lock
and runbundle install
. Nothing changed, same error.The gem in question is Act as taggable on.
解决方案First I did a
gem q --L
, the shortcut forgem query --local
. It outputs me the all the local gems installed.actionmailer (3.2.8, 3.2.6, 3.2.1, 3.1.0) actionpack (3.2.8, 3.2.6, 3.2.1, 3.1.0) activemodel (3.2.8, 3.2.6, 3.2.1, 3.1.0) activerecord (3.2.8, 3.2.6, 3.2.1, 3.1.0) activeresource (3.2.8, 3.2.6, 3.2.1, 3.1.0) activesupport (3.2.8, 3.2.6, 3.2.1, 3.1.0) acts-as-taggable-on (2.3.3) ...
And then, following DVG advice, I uninstalled the gem using its correct name
gem uninstall acts-as-taggable-on
and ranbundle install
. After that I was able torails c
orrails s
again without any problem.这篇关于如何使用捆绑器重新安装宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!