I'm running bundler v1.3.0.pre.2 and trying to get bundler to bundle a local git repository holding a gem, into a rails app.
我正在运行bundler v1.3.0.pre.2并试图让bundler将一个拥有gem的本地git存储库捆绑到rails应用程序中。
Gemfile :
Gemfile:
gem 'mygem', :github => 'myrepo/mygem', :branch => 'develop'
Config :
配置:
bundle config local.mygem /path/to/local/git/repo
Bundle install throws the error :
Bundle install抛出错误:
Local override for mygem at /path/to/local/git/repo is using branch develop but Gemfile specifies develop
mygem在/ path / to / local / git / repo的本地覆盖是使用分支开发,但Gemfile指定develop
Is this a bug ? I see that the branch names are exactly the same. What could be wrong ? Got the same error for Bundler v1.2.3 as well
这是一个错误吗?我看到分支名称完全相同。可能有什么不对?对于Bundler v1.2.3也有同样的错误
4 个解决方案
#1
9
You can use a local gem and even the branch you are working on like this
您可以使用本地gem甚至是您正在处理的分支
gem 'rspec-rails', path: '~/forks/rspec-rails', branch: 'feature-branch'
Just change github
to path
, Then
只需将github更改为path,然后
bundle install
Also as far as bundler config goes, although it is in the docs, I have never needed to change the local config like you did above.
另外,就Bundler配置而言,虽然它在文档中,但我从来没有像上面那样更改本地配置。
With this method I have never needed to remove Gemfile.lock
, it just picks up the changes to your local repo.
使用这种方法,我从来不需要删除Gemfile.lock,它只是获取对本地仓库的更改。
Although I don't recommend it, you could disable the branch checking feature used by bundler to make sure you are using the correct branch when developing
虽然我不推荐它,但您可以禁用bundler使用的分支检查功能,以确保在开发时使用正确的分支
bundle config disable_local_branch_check true
#2
5
If you just need to point to a branch within a local repository you're using like a gem, in gemfile:
如果您只需要指向本地存储库中的分支,那么您在gemfile中就像gem一样使用:
gem 'gem-name', :path=> 'relative/path/to/directory'
Then create bundler configuration for that "gem" before bundle
-ing
然后在捆绑之前为该“gem”创建bundler配置
(Keep in mind the repository name may be different than the gem's name, although this is not the norm).
(请记住,存储库名称可能与gem的名称不同,尽管这不是常态)。
bundle config local.repository-name relative/path/to/directory
Magically, whatever branch is currently checked out locally will be active when you start a local server. You'll likely need to restart your server if you need to make changes or change branches (unless you have some type of automatic reloading feature).
奇怪的是,当您启动本地服务器时,当前在本地检出的任何分支都将处于活动状态。如果需要进行更改或更改分支,则可能需要重新启动服务器(除非您具有某种类型的自动重新加载功能)。
One gotcha is when a configuration setting is already established (let's say via the mechanism above), and you need to use/reference a remote git gem - you don't need bundler configuration to use a remote git gem (if you have an active configuration, you'll get the local override
error).
一个问题是当配置设置已经建立时(让我们说通过上面的机制),你需要使用/引用一个远程git gem - 你不需要捆绑器配置来使用远程git gem(如果你有一个活跃的配置,你会得到本地覆盖错误)。
Check to make sure you don't have local settings for given gem:
检查以确保您没有给定gem的本地设置:
bundle config local.gem-name
If you do, remove configuration for that gem:
如果这样做,请删除该gem的配置:
bundle config --delete local.gem-name
Then point to remote repo and branch, in gemfile:
然后在gemfile中指向远程repo和branch:
gem 'gem-name', :path => 'https://github.com/reponame.git', :branch => 'branch_name'
More information:
更多信息:
Git Gems: http://bundler.io/v1.7/git.html
Git Gems:http://bundler.io/v1.7/git.html
"bundle config": http://bundler.io/v1.7/man/bundle-config.1.html
“bundle config”:http://bundler.io/v1.7/man/bundle-config.1.html
#3
1
The branch you reference in your Gemfile needs to be the same as you have checked out in the local repository. Note that after you commit in the local repository you will need to run bundle install on your main application so that it rebuilds the Gemfile.lock to include the new revision hash and commit it. I recommend using the gem below as it automates this process for you and also aids in other scenarios. See the gem page for exact detail.
您在Gemfile中引用的分支需要与在本地存储库中签出的分支相同。请注意,在本地存储库中提交后,您需要在主应用程序上运行bundle install,以便重新构建Gemfile.lock以包含新的版本哈希并提交它。我建议使用下面的gem,因为它可以为您自动执行此过程,也可以帮助其他方案。有关详细信息,请参阅gem页面。
https://github.com/EPI-USE-Labs/git-bundle
https://github.com/EPI-USE-Labs/git-bundle
Full detail of what happens:
发生的事情的全部细节:
When you use a git repository in your gemfile you can use bundle local overrides for development which will store revision hashes in your Gemfile.lock. On production these exact revision hashes will be checked out when it runs bundle install.
在gemfile中使用git存储库时,可以使用bundle本地覆盖进行开发,这将在Gemfile.lock中存储修订哈希。在生产时,这些精确的修订版哈希将在运行bundle install时检出。
Gemfile: gem 'example', git: 'https://github.com/your_name/example.git', branch: :master
Gemfile:gem'example',git:'https://github.com/your_name/example.git',branch :: master
Bundle config shell command: bundle config local.example /path/to/local/git/repository
Bundle config shell命令:bundle config local.example / path / to / local / git / repository
Gemfile.lock (auto generated): GIT remote: https://github.com/your_name/example.git revision: b9270e61abb89e1ff77fb8cfacb463e4d04388ad branch: master
Gemfile.lock(自动生成):GIT远程:https://github.com/your_name/example.git修订版:b9270e61abb89e1ff77fb8cfacb463e4d04388ad分支:master
#4
0
This GitHub issue suggests that the workaround may be to remove Gemfile.lock
and do bundle install
again.
此GitHub问题表明,解决方法可能是删除Gemfile.lock并再次执行bundle install。
#1
9
You can use a local gem and even the branch you are working on like this
您可以使用本地gem甚至是您正在处理的分支
gem 'rspec-rails', path: '~/forks/rspec-rails', branch: 'feature-branch'
Just change github
to path
, Then
只需将github更改为path,然后
bundle install
Also as far as bundler config goes, although it is in the docs, I have never needed to change the local config like you did above.
另外,就Bundler配置而言,虽然它在文档中,但我从来没有像上面那样更改本地配置。
With this method I have never needed to remove Gemfile.lock
, it just picks up the changes to your local repo.
使用这种方法,我从来不需要删除Gemfile.lock,它只是获取对本地仓库的更改。
Although I don't recommend it, you could disable the branch checking feature used by bundler to make sure you are using the correct branch when developing
虽然我不推荐它,但您可以禁用bundler使用的分支检查功能,以确保在开发时使用正确的分支
bundle config disable_local_branch_check true
#2
5
If you just need to point to a branch within a local repository you're using like a gem, in gemfile:
如果您只需要指向本地存储库中的分支,那么您在gemfile中就像gem一样使用:
gem 'gem-name', :path=> 'relative/path/to/directory'
Then create bundler configuration for that "gem" before bundle
-ing
然后在捆绑之前为该“gem”创建bundler配置
(Keep in mind the repository name may be different than the gem's name, although this is not the norm).
(请记住,存储库名称可能与gem的名称不同,尽管这不是常态)。
bundle config local.repository-name relative/path/to/directory
Magically, whatever branch is currently checked out locally will be active when you start a local server. You'll likely need to restart your server if you need to make changes or change branches (unless you have some type of automatic reloading feature).
奇怪的是,当您启动本地服务器时,当前在本地检出的任何分支都将处于活动状态。如果需要进行更改或更改分支,则可能需要重新启动服务器(除非您具有某种类型的自动重新加载功能)。
One gotcha is when a configuration setting is already established (let's say via the mechanism above), and you need to use/reference a remote git gem - you don't need bundler configuration to use a remote git gem (if you have an active configuration, you'll get the local override
error).
一个问题是当配置设置已经建立时(让我们说通过上面的机制),你需要使用/引用一个远程git gem - 你不需要捆绑器配置来使用远程git gem(如果你有一个活跃的配置,你会得到本地覆盖错误)。
Check to make sure you don't have local settings for given gem:
检查以确保您没有给定gem的本地设置:
bundle config local.gem-name
If you do, remove configuration for that gem:
如果这样做,请删除该gem的配置:
bundle config --delete local.gem-name
Then point to remote repo and branch, in gemfile:
然后在gemfile中指向远程repo和branch:
gem 'gem-name', :path => 'https://github.com/reponame.git', :branch => 'branch_name'
More information:
更多信息:
Git Gems: http://bundler.io/v1.7/git.html
Git Gems:http://bundler.io/v1.7/git.html
"bundle config": http://bundler.io/v1.7/man/bundle-config.1.html
“bundle config”:http://bundler.io/v1.7/man/bundle-config.1.html
#3
1
The branch you reference in your Gemfile needs to be the same as you have checked out in the local repository. Note that after you commit in the local repository you will need to run bundle install on your main application so that it rebuilds the Gemfile.lock to include the new revision hash and commit it. I recommend using the gem below as it automates this process for you and also aids in other scenarios. See the gem page for exact detail.
您在Gemfile中引用的分支需要与在本地存储库中签出的分支相同。请注意,在本地存储库中提交后,您需要在主应用程序上运行bundle install,以便重新构建Gemfile.lock以包含新的版本哈希并提交它。我建议使用下面的gem,因为它可以为您自动执行此过程,也可以帮助其他方案。有关详细信息,请参阅gem页面。
https://github.com/EPI-USE-Labs/git-bundle
https://github.com/EPI-USE-Labs/git-bundle
Full detail of what happens:
发生的事情的全部细节:
When you use a git repository in your gemfile you can use bundle local overrides for development which will store revision hashes in your Gemfile.lock. On production these exact revision hashes will be checked out when it runs bundle install.
在gemfile中使用git存储库时,可以使用bundle本地覆盖进行开发,这将在Gemfile.lock中存储修订哈希。在生产时,这些精确的修订版哈希将在运行bundle install时检出。
Gemfile: gem 'example', git: 'https://github.com/your_name/example.git', branch: :master
Gemfile:gem'example',git:'https://github.com/your_name/example.git',branch :: master
Bundle config shell command: bundle config local.example /path/to/local/git/repository
Bundle config shell命令:bundle config local.example / path / to / local / git / repository
Gemfile.lock (auto generated): GIT remote: https://github.com/your_name/example.git revision: b9270e61abb89e1ff77fb8cfacb463e4d04388ad branch: master
Gemfile.lock(自动生成):GIT远程:https://github.com/your_name/example.git修订版:b9270e61abb89e1ff77fb8cfacb463e4d04388ad分支:master
#4
0
This GitHub issue suggests that the workaround may be to remove Gemfile.lock
and do bundle install
again.
此GitHub问题表明,解决方法可能是删除Gemfile.lock并再次执行bundle install。