Tag: gem

RVMruby如何找到gem?

我在Mac OS X(10.9.2)下使用RVM下的Ruby 1.8.6。 我安装了一切本地用户(不是root用户),然后安装了一个gem: gem install gli -v 1.6 当我使用require(‘gli’)运行ruby时,我收到错误: in `require’: no such file to load — gli (LoadError) 即使gem list显示gli (1.6.0) 。 我不确切知道RVM如何处理它的gemsets,但$LOAD_PATH中的任何目录中都没有gli.rb文件。 RVM如何与$LOAD_PATH交互以在$LOAD_PATH中找到必要的gem?

由于sqlite3 gem错误,Heroku部署失败

我刚刚开始阅读Michael Hartl撰写的ruby.railstutorial.org书,并一直在完成第一章。 我正在使用mac book OS X,Terminal和Sublime Text。 一切都按计划进行,直到测试部署到Heroku为止。 我能够连接到Heroku并运行$ git push heroku master命令。 但部署失败: Installing sqlite3 (1.3.5) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/bin/ruby extconf.rb checking for sqlite3.h… no sqlite3.h is missing. Try ‘port install sqlite3 +universal’ or ‘yum install sqlite-devel’ and check your shared library search path (the location […]

使用Jruby而不是Ruby创建gem

所以我成功地编写了一个jruby文件并从jar文件中读取。 我还创建了一个单独的Ruby gem,安装它并成功使用它。 我想用Jruby(而不是ruby)写一个gem。 当我尝试这样做并在安装gem之后,它给了我以下错误: `require’: cannot load such file — java (LoadError) 是否有一种使用jruby编写gem的特定方法,这与编写gem usig ruby​​的方式不同? 如果是这样,请指导我一个有用的教程,帮助我使用jruby创建一个gem 谢谢。 编辑: 我将以下内容添加到jruby_gem.gemspec文件中 s.platform = ‘java’ 使用命令构建gem: gem build jruby_gem.gemspec 并使用以下命令安装它: gem install jruby_gem-0.0.0 当我尝试使用命令运行它时: irb require ‘jrubt_gem’ 我仍然有同样的错误。

Ruby没有安装json -v 1.8.1作为bundle的一部分,ERROR:无法构建gem原生扩展

我已尝试使用作为捆绑包的一部分并使用sudo进行安装,但每次都会收到相同的错误消息。 我目前使用的是Ruby 2.0.0 and Rails 4.1.8 。 我不确定发生了什么。 以下确切的错误消息: 从https://rubygems.org/获取gem元数据………. 解决依赖关系…… 使用rake 10.4.2使用i18n 0.6.11 Gem :: Ext :: BuildError:错误:无法构建gem原生扩展。 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141218-80226-brqexc.rb extconf.rb mkmf.rb在/ System / Library中找不到ruby的头文件/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h extconf失败,退出代码1 Gem文件将保留在/Library/Ruby/Gems/2.0.0/gems/json-1.8.1中进行检查。 结果记录到/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/json-1.8.1/gem_make.out安装json(1.8.1)时发生错误,而Bundler无法继续。 在捆绑之前确保gem install json -v ‘1.8.1’成功。 任何建议表示赞赏

如何初始化rails gem,它将关联添加到用户指定的模型

我正在创建一个gem,它需要为用户定义的某些模型添加关联。 我有一个初始化文件,可以通过rails生成器命令将其复制到应用程序中,这是用户将指定要添加关联的模型的位置。 BloggyGem.setup do |config| config.user = User config.post = Post end gem内部,我有这个指定 opts = BloggyGem.settings opts.user.has_many opts.post.to_s.downcase.pluralize.to_sym, :class_name => opts.post.model_name opts.post.belongs_to opts.user.to_s.downcase.singularize.to_sym, :class_name => opts.user.model_name 我的测试是在传递我的gem,但导轨初始化略有不同,所以想要确保最好的方法。

查找其他用户在post上收到的用户总票数

我正在使用这个gem评论: https : //github.com/lml/commontator 哪个设置很容易插入这个gem投票评论: https : //github.com/ryanto/acts_as_votable 我正在使用rails 4 btw,它与两个gem兼容。 在我的用户模型中: class User < ActiveRecord::Base acts_as_voter acts_as_commentator has_many :comments end 在我的评论模型中: class Comment < ActiveRecord::Base acts_as_votable belongs_to :user end 一切似乎都很好。 但是在尝试计算用户总票数时(用户在所有评论中收到的总票数)(业力) 我收到这个错误 undefined method `votes’ for # 所以我尝试了这个: 这导致了另一个错误: SQLite3::SQLException: no such column: commontator_comments.commontator_id: SELECT “commontator_comments”.* FROM “commontator_comments” WHERE “commontator_comments”.”commontator_id” = ? AND “commontator_comments”.”commontator_type” […]

Gem的模型遗失了

我在我的Rails 4应用程序中使用邮箱 。 gem ‘mailboxer’ 我最近将它从0.11更新到0.12.4 ,它停止工作,我无法找出原因。 现在,我收到错误: uninitialized constant Message 我检查了gem的GitHub repo ,它确实有Message模型。 我检查了我的本地版本的gem,它匹配。 Puma:mailboxer Jeff$ pwd /Users/Jeff/.rvm/gems/ruby-2.0.0-p247/gems/mailboxer-0.12.4/app/models/mailboxer Puma:mailboxer Jeff$ ls conversation conversation.rb mailbox.rb message.rb notification.rb receipt.rb 为什么我的应用程序找不到该模型? 我该如何解决?

Rubygems被Norton DNS阻止

我跑了 $ gem fetch -V github-linguist GET http://rubygems.org/latest_specs.4.8.gz 302 Moved Temporarily GET http://production.s3.rubygems.org/latest_specs.4.8.gz 200 OK ERROR: While executing gem … (Zlib::GzipFile::Error) not in gzip format 然后我震惊地在浏览器中打开链接并看到此消息 诺顿DNS 恶意网站被阻止 您试图访问:production.s3.rubygems.org 这是一个已知的恶意网站。 建议您不要访问 这个网站。 这个站点指向production.s3.rubygems.org.s3.amazonaws.com, 这是恶意的。 在铅笔的建议下,我运行了namebench并切换到了OpenDNS-2。

在Windows上安装libbzip2

我试图在Windows 7上安装libbzip2。(其实我想安装wp2txt包,但似乎需要libbzip2)。 我按照Alex的建议安装了“Bzip2 for Windows”。 但我得到以下错误。 C:\Users\John>gem install bzip2-ruby — –with-bz2-include=”C:\Program Files (x86)\GnuWin32\include” — –with-bz2-lib=”C:\Program Files (x86)\GnuWin32\lib” Temporarily enhancing PATH to include DevKit… Building native extensions. This could take a while… ERROR: Error installing bzip2-ruby: ERROR: Failed to build gem native extension. C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb –with-bz2-include=C:\Program Files (x86)\GnuWin32\include — –with-bz2-lib=C:\Program Files (x86)\GnuWin32\lib checking for bzlib.h… no […]

Ubuntu 12.10,Ruby 1.9.3上的Compass gemfile语法错误

运行安装rvm的标准程序,也安装了Ruby 1.9.3,然后为rake,compass,sass,bundler和guard安装gems,然后将我的gems / bin目录添加到我的路径中,我在运行指南针上收到以下消息: /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler/dsl.rb:35:in `rescue in eval_gemfile’: Gemfile syntax error: (Bundler::GemfileError) gem “guard”, “~> 1.0.1” ^ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler/dsl.rb:32:in `eval_gemfile’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler/dsl.rb:7:in from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler/definition.rb:18:in `build’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler.rb:144:in `definition’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler.rb:112:in `setup’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/bundler-1.2.3/lib/bundler.rb:128:in `require’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/gems/compass-0.12.2/bin/compass:26:in `’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/bin/compass:19:in `load’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/bin/compass:19:in ` from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval’ from /home/m1ke/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `’ 所有的gem都安装了标准的gem install compass语法,我也运行了gem update –system 更多信息! […]