构建后缺少Gem中的文件 [英] Missing File in Gem after Build

查看:98
本文介绍了构建后缺少Gem中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR:



不要在现有的git存储库中运行bundle。奇怪的事情会发生,没有任何错误信息。



原始问题:

我通过调整本教程中的步骤构建了一个gem:

http://net.tutsplus.com/tutorials/ruby/gem-creation-with-bundler/



作为最后一步,我运行了gem build .gemspec这个成功了,但是当我安装gem时,我发现了一个关键文件,我的代码,不在宝石中。在同一个(lib)目录中的另一个文件version.rb确实存在于gem中。



我不知道如何开始调试... bundler / gem build如何决定哪些文件包含在gem中?



编辑:



我的工作流程是:

  gem build< project_name> .gemspec 
gem unpack< project_name>
=>确认文件不存在于< unpacked> / lib /

gem install<项目名称>
=>确认〜/ home / stefan / .rvm / ...中的文件结构包含gem,但不包含所需的文件


$ b $编辑2 /解决方案



我终于可以通过将所有代码提交到远程存储库,一个干净的克隆,并建立宝石。新宝石包含了所有必需的文件。



有点历史......我最初创建了代码,并在考虑制作宝石之前提交它(这是我的第一个宝石)。然后,我在原始存储库中使用了bundle ,它并没有抱怨,但可能是造成这个怪异的原因。

解决方案

Bundler为你做的一件事是启动一个本地git仓库来管理你的gem代码。检查你是否在git中添加了文件

  git add lib / gem_name / missing_file.rb 

Bundler生成的gem在内部使用git来跟踪gem源文件的成员资格。您可以在.gemspec中看到它,它使用反引号调出git并生成文件列表:

  gem.files =`git ls-files`.split($ /)

注意这也意味着您应该注意您在 .gitignore

中列出的内容

TL;DR:

Don't run bundle within an existing git repository. Weird things will happen without any error messages.

Original Question:

I've built a gem by adapting the steps in this tutorial:

http://net.tutsplus.com/tutorials/ruby/gem-creation-with-bundler/

As a final step, I've run gem build .gemspec

This succeeds, but when I install the gem I find the critical file, the one which contains my code, isn't in the gem. Another file in the same (lib) directory, "version.rb", does exist in the gem.

I don't know how to start debugging this...how does bundler/gem build decide which files to include in the gem?

Edit:

My workflow is:

gem build <project_name>.gemspec
gem unpack <project_name>
=> confirm file does not exist in <unpacked>/lib/

gem install <project name>
=> confirm file structure in ~/home/stefan/.rvm/... contains gem, but does not contain desired file

Edit 2 / Resolution:

I was finally able to get this working by committing all my code to a remote repository, creating a clean clone, and building the gem. The new gem included all the required files.

A bit of history...I originally created the code and committed it before thinking about making a gem (this is my first gem). I then used bundle inside the original repository, which didn't complain, but was probably the reason for the weirdness.

解决方案

One of the things bundler did for you is start a local git repo to version-manage your gem code. Check that you have added the file in git

git add lib/gem_name/missing_file.rb

Bundler generated gems use git internally to track "membership" of source files for the gem. You can see this in the .gemspec where it uses backticks to call out to git and generate a file list:

gem.files         = `git ls-files`.split($/)

Note this also means you should pay attention to what you list in .gitignore

这篇关于构建后缺少Gem中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆