我正在运行Mac OSX 10.9.1,我正在使用RVM来管理Ruby v2.0.0-p353.
当我尝试安装Rails时出现此错误:
Ryans-MacBook-Air-2:~ ryan$ gem install rails
ERROR: Error installing rails:
invalid gem: package is corrupt, exception while verifying: undefined method`path2class' for #<Psych::ClassLoader:0x0000010c9d0be0> (NoMethodError) in /Users/ryan/.rvm/gems/ruby-2.0.0-p353/cache/i18n-0.6.9.gem
Run Code Online (Sandbox Code Playgroud)
这是我安装的宝石列表:
Ryans-MacBook-Air-2:~ ryan$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.3, 1.2.0)
bundler (1.5.1)
bundler-unload (1.0.2)
executable-hooks (1.2.6)
gem-wrappers (1.2.1)
io-console (0.4.2)
json (1.8.1, 1.7.7)
minitest (5.2.0, 4.3.2)
psych (2.0.2, 2.0.0)
rake (10.1.1, 0.9.6)
rdoc (4.1.0, 4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.8)
test-unit (2.5.5, 2.0.0.0)
Run Code Online (Sandbox Code Playgroud)
有没有人有解决这个问题的建议?
我跑步时遇到奇怪的捆绑错误
bundle pack
Run Code Online (Sandbox Code Playgroud)
与bundler 0.9.12
有任何想法吗?(有关更好的格式化代码,请参阅pastie:http://pastie.org/881328 )
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize': not in gzip format (Zlib::GzipFile::Error)
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `new'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:63:in `each'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:54:in `loop'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:54:in `each'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:32:in `initialize'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:17:in `new'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:17:in `open'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/package.rb:55:in `open'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/format.rb:63:in `from_io'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/format.rb:51:in `from_file_by_path'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/format.rb:50:in `open'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/format.rb:50:in `from_file_by_path'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/source.rb:115:in `specs'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/source.rb:114:in `each'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/source.rb:114:in `specs'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/index.rb:32:in `from_cached_specs'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/index.rb:23:in `application_cached_gems'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/index.rb:15:in `cached_gems'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/index.rb:5:in `build'
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/bundler-0.9.12/lib/bundler/index.rb:14:in `cached_gems'
from …Run Code Online (Sandbox Code Playgroud) 场景:我正在gem-foo使用Bundler 开发一个gem .我有一个依赖gem-bar,我已经在本地检查开发.我可以在Gemfileas中声明这个依赖:
gem "gem-bar", :path => "/path/to/local/gem-bar"
Run Code Online (Sandbox Code Playgroud)
然而,在开发宝石时,"最佳实践"似乎是在gem-foo.gemspec通道中定义所需的宝石:
s.add_runtime_dependency 'gem-bar'
Run Code Online (Sandbox Code Playgroud)
然后简单地在Gemfile使用中包含依赖项:
gemspec
Run Code Online (Sandbox Code Playgroud)
我想要做的是在gemspec中添加对gem的运行时依赖性,但是对其进行一些本地修改gem-bar并bundle install使用本地开发结帐.假设我控制两个宝石的情况,并且我在某种程度上同时攻击它们,我将同时推动新版本.我可能只是注释掉s.add_runtime_dependency在gemspec并与在Gemfile中的本地路径添加它,但那种感觉......容易出错?gemspec 应该总是声明这个依赖项,并且Gemfile应该能够覆盖Bundler应该用于gem的位置.但是,如果您实际执行此操作,则会收到以下错误:
您不能指定来自不同来源的相同gem两次.您指定gem-bar(> = 0)应来自未指定的源和/ path/to/local/gem-bar的源
理想情况下,我只是有一些本地覆盖,因为我从来不想要我不小心推动宝石需要gem-bar在特定路径上的本地.那会很愚蠢.
有没有人对这个用例有一个很好的解决方案?
Gemfile说:
gem 'sqlite3', :groups => [:development, :test]
gem 'mysql2', :group => :production
Run Code Online (Sandbox Code Playgroud)
然而,当我bundle install在我的开发机器上打字时,安装了所有宝石.
我的设置有什么问题?
最近我的一个黄瓜场景出了问题.功能运行时,我的测试数据库中的某些条目正在消失.我通过改变线来解决问题
DatabaseCleaner.strategy = :transaction
Run Code Online (Sandbox Code Playgroud)
至
DatabaseCleaner.strategy = :truncation
Run Code Online (Sandbox Code Playgroud)
我不确定为什么这有帮助.数据库清理工具宝石网页上有一个表格,但它并没有真正说出这两个术语的含义.任何帮助理解这两个概念之间的差异都会很棒.
我正在研究一个gem,它需要在安装gem时有条件地设置依赖项.我做了一些挖掘
看起来我并不孤单.
http://www.ruby-forum.com/topic/957999
我可以看到向gem添加依赖项的唯一方法是在.gemspec文件中的Gem :: Specifiction块中使用add_dependency方法
Gem::Specification.new do |s|
# ... standard setup stuff
# conditionally set dependencies
s.add_dependency "rb-inotify", "~> 0.8.8" if RUBY_PLATFORM =~ /linux/i
s.add_dependency "rb-fsevent", "~> 0.4.3.1" if RUBY_PLATFORM =~ /darwin/i
s.add_dependency "rb-fchange", "~> 0.0.5" if RUBY_PLATFORM =~ /mswin|mingw/i
end
Run Code Online (Sandbox Code Playgroud)
基于我在网上找到的所有文档和线程,我希望如果你安装gem
但是,似乎并非如此.块中的"if"语句在构建和打包gem时进行评估.因此,如果您在Linux上构建并打包gem,那么,rb-inotify将作为依赖项添加,然后是rb-fsevent,Windows-rb-fchange.
仍然需要一个解决方案,我在rubygems代码中挖掘出来,似乎以下内容是对发生的事情的广泛描述.
看来,当宝石是建立和释放的foo.gemspec文件被加载并在宝石::规格块被评估并转换为YAML,压缩为metadata.gz,并包含在foo.gem.ruby代码被压缩成data.tar.gz并包含在内.当gem安装在本地开发人员机器上时,YAML从metadata.gz中提取并转换回Gem :: Specification块,但是,它不会转换回原始块.
相反,你会看到如下内容:
Gem::Specification.new do |s|
if s.respond_to? :specification_version then
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rb-inotify>, …Run Code Online (Sandbox Code Playgroud) Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/activemodel-3.2.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0xb5f9c990> 3.2.0"]
Run Code Online (Sandbox Code Playgroud)
从尝试为其他问题做sudo gem更新
获得这个数百次的时间,因为sudo gem update会遍历每个gem并获取大部分内容的消息
我想在Ruby中可视化我的一些统计学计算.
我的问题是,我无法找到合适的宝石.
rsruby似乎不是最新的,我无法在Ruby 1.9.2中安装它.
你知道如何在Ruby中运行R命令吗?
我正在研究一种宝石(宝石A),它使用了我也写过的另一种宝石(宝石B).在此之前,Gem B已添加到Gem A的gemspec中:
gem.add_dependency "gem_a", "~> 0.0.4"
Run Code Online (Sandbox Code Playgroud)
但我现在发现需要使用我的本地版本进行调试.
要在Gemfile中声明本地依赖项,我可以这样做:
gem 'gem_a', path: "/local/path/to/gem_a"
Run Code Online (Sandbox Code Playgroud)
但是如何在a中声明一个本地依赖.gemspec?
编辑:找到答案(见下面的答案!).它涉及使用版本1.4.2而不是1.4.3,所以如果有人对1.4.3工作有任何想法,那也可能有用.谢谢!
编辑2:感谢下面的评论,似乎1.4.3在Windows上运行时确实有问题.https://github.com/jekyll/jekyll/issues/1948
我刚刚在我的Windows 7计算机上安装了jekyll.我和开发包一起安装了ruby.
我已经跑了gem install jekyll,并且成功完成了.我根据jekyll文档创建了一个新站点.
我遇到的问题发生在我尝试运行时jekyll serve.请在下面找到错误输出.
PS C:\jekyll\test-site> jekyll serve --trace
Configuration file: C:/jekyll/test-site/_config.yml
Source: C:/jekyll/test-site
Destination: C:/jekyll/test-site/_site
Generating... C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Invalid argument - C:/jekyll/test-site/_site/C: (Errno::EINVAL)
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:205:in `each'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/convertible.rb:168:in `write'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:259:in `block in write'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:397:in `block (2 levels) in each_site_file'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:396:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:396:in `block in …Run Code Online (Sandbox Code Playgroud) gem ×10
ruby ×6
bundler ×3
rubygems ×3
dependencies ×2
conditional ×1
cucumber ×1
database ×1
gemspecs ×1
install ×1
jekyll ×1
r ×1
rspec ×1
rvm ×1
statistics ×1
transactions ×1