未定义的局部变量或Gemfile的方法`git_source’

从github克隆一个rails应用程序,使用相同版本的rails(5.0.1)在原始dev的机器上运行。

从app目录运行的任何rails命令都会失败:

Undefined local variable or method `git_source' for Gemfile 

相关的Gemfile部分:

 git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end 

git_source是在Bundler 1.6.0中引入的。

要更新捆绑程序运行:

 $ gem update bundler 

在你的控制台中,运行…

 gem update bundler bundle install 

我遇到了同样的问题。 $ gem update bundler没有帮助。 我通过控制台安装了一个缺少的gem,然后使用RubyMine Gem Manager安装其余的(或sudo bundle install)。 它对我有用。

我的问题

sample_app $ bundle install – withoutout production

未定义的局部变量或Gemfile的方法`git_source’

sample_app $ ruby​​ -v

ruby 1.9.3p484(2013-11-22修订版43786)[i686-linux]

我的解决方案

 /bin/bash --login 

rvm使用2.4.0

 /sample_app $ ruby -v 

ruby 2.4.0p0(2016-12-24修订版57164)[i686-linux]

sample_app $ bundle install – withoutout production

捆绑完成!