Rails找不到JSON gem但是bundle install可以吗?

时间:2015-11-09 18:35:06

标签: ruby-on-rails json gem bundle osx-elcapitan

刚升级到OS X El Capitan并尝试自升级以来首次创建新的rails应用程序。在几个障碍(和很多谷歌搜索)后,我终于创建了应用程序。当我尝试使用int func(int x) // returns 0 if there is no valid palindrome { int arr[10] = {0,0,0,0,0,0,0,0,0,0}; // it is digits counter while (x) // this is executed for each digit in the number { arr[x%10]++; // here x%10 is equal to current digit x /= 10; // remove rightmost digit } for (int i = 0; i < 10; i++) { if (arr[i] % 2) // Every digit must be repeated 0,2,4,6 or 8 times. If it's not, then there is no valid palindrome { return 0; } } int ret = 0; // this is our future result // Now we just take largest digit that appears in source number and add it to the result. If it appears twice, we add it once. If it appears 4 times, we add it twice and so on. for (int i = 9; i >= 0; i--) { for (int j = 0; j < arr[i]/2; j++) { ret = ret * 10 + i; } } // Now we're doing same thing in the reverse direction. for (int i = 0; i < 10; i++) { for (int j = 0; j < arr[i]/2; j++) { ret = ret * 10 + i; } } return ret; // we're done now } 创建新模型时,我收到此错误:

rails g model Mymodel

当我运行 Could not find json-1.8.3 in any of the sources Run `bundle install` to install missing gems. 时,我明白了:

bundle install

当我运行 Resolving dependencies... Using rake 10.4.2 Using i18n 0.7.0 Using json 1.8.3 ... Bundle complete! 13 Gemfile dependencies, 54 gems now installed. Use `bundle show [gemname]` to see where a bundled gem is installed. 时,我得到:

bundle show json

我知道导轨设置的基础知识但是这样的任何故障排除一直都在我的脑海中。我想解决方案可能很简单,但谷歌搜索没有给我任何东西。也许我只是没有用正确的措辞来搜索。无论如何,有没有人知道发生了什么以及如何解决它?

非常感谢!

更新

当我尝试卸载时,我可以重新安装,我收到错误:

    /usr/local/lib/ruby/gems/2.2.0/gems/json-1.8.3

更新2:

我做的唯一不同于我创建的其他新应用程序是添加引导程序。在我的Gemfile中,我有:

    ERROR:  While executing gem ... (Gem::InstallError)
    gem "json" cannot be uninstalled because it is a default gem

我想也许其中一个导致了这个问题,所以我开始从我的Gemfile中删除autoprefixer gem。然后我运行了 gem 'bootstrap-sass' gem 'autoprefixer-rails' 命令,我收到了这个错误:

g model

与上一个错误相同但具有不同的gem。所以,我把gem放回到Gemfile中,我仍然遇到了这个错误。我不知道是怎么回事。有什么想法吗?

0 个答案:

没有答案