Cannot install metric_fu, how to switch to simplecov? - ruby

I tried to install metric_fu against my Ruby 1.9 environment, but it failed due to the problem below:
$ gem install metric_fu
...
Fetching: rcov-1.0.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing metric_fu:
ERROR: Failed to build gem native extension.
/Users/xxx/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
**** Ruby 1.9 is not supported. Please switch to simplecov ****
It says "switch to simplecov", but how to do that?
UPDATE: Resoved after installing rcov 0.9.11. I found the same issue here:
https://github.com/iain/metrical/issues/12

You can use SimpleCov by adding
gem 'simplecov', :require => false
to your gem file in the test group, and then add into your spec_helper.rb:
require 'simplecov'
SimpleCov.start
then just open coverage/index.html and you get SimpleCov in the browser. It's really excellent.

I'm the new maintainer of metric_fu and it should work now on ruby 1.9 without any problems. See configuration instructions at https://github.com/metricfu/metric_fu which include how you can have metric_fu load external coverage output (e.g. using simplecov)
Rcov on ruby 1.9 segfaults and fails a lot, so running it is disabled by default and the gem is no longer included as a dependency. However, you may still config it to run or load coverage stats you've already generated
Also, it works from the command-line now. Now need to bundle it or run rake or metrical

Try rcov 0.9.11 as described here.
add to Gemfile (test section)
gem "rcov", "0.9.11"
rerun bundle install
run tests with bundle exec of course.

Related

Travis CI Build doesn't install gems for JRuby platform

I have a travis build set up for my project that also run on JRuby. I mention the activerecord-jdbcsqlite3-adapter gem in the Gemfile for the :jruby platform:
platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
end
but the build still always fails with the message LoadError: Please install the sqlite3 adapter:gem install activerecord-sqlite3-adapter(sqlite3 is not part of the bundle. Add it to Gemfile.) and the gem actually doesn't get installed.
The project is open source at https://github.com/simplabs/rails_api_auth, the build is at https://travis-ci.org/simplabs/rails_api_auth.
On travis-ci for sqlite3 the docs seem to indicate you need 'jdbc-sqlite3:
platforms: jruby do
gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
end
EDIT
Actually I think your real problem is that you checked-in your Gemfile lock files (Gemfile.lock && gemfiles/*.lock). Travis-ci isn't re-evaluating what Gems are needed for the particular platforms.
what happens if you do?:
platforms :jruby do
gem 'sqlite3'
gem 'activerecord-jdbcsqlite3-adapter'
end
maybe the adapter is still relying on classes from the sqlite3 gem (thats what i read from the errors so far)

gem install fails with "Could not find a valid gem 'yaml'"

I'm building a gem from a currently working ruby program. It's using jruby 1.7.12 and, among other things, does a "require 'yaml". For the gem, my Gemfile contains:
source 'https://rubygems.org'
gemspec
When I run
gem build program.gemspec
that works just fine, but when I run
gem install program-0.15.01.gem
it fails with
ERROR: Could not find a valid gem 'yaml' (>= 0) in any repository
ERROR: Possible alternatives: aml, cyaml, haml, maml, raml
Doesn't make any sense since the yaml module is part of the ruby 1.9.3 standard library.
I've upgraded to the latest rubygems (2.4.5).
What the heck am I missing?
yaml is part of Ruby. There is no yaml gem (see https://rubygems.org/search?query=yaml).
Therefore remove
s.add_runtime_dependency 'yaml'
from your gemspec and just add require 'yaml' to the file in which you want to use YAML.

Ruby Gem not install dependency

I created a Ruby Gem and published it. I tried downloading it and I keep getting cannot require my dependent gem. The code is at https://github.com/wallerjake/toolshed and the gem in question is httparty. The error that I am getting is
~/.rvm/gems/ruby-2.0.0-p353#sullivan_cotter/bundler/gems/toolshed-46404c5af06d/lib/toolshed.rb:2:in `require': cannot load such file -- httparty (LoadError)
I have updated my https://github.com/wallerjake/toolshed/blob/master/toolshed.gemspec to use add_dependency instead but that doesn't seem to be helping. Could it be conflicting with other Gems?
The version on rubygems is still the old one with only development dependencies. Worked fine when I downloaded and built you gem from Github.
Yes sorry I solved this by adding them as a dependency not a development dependency.
spec.add_dependency "httparty"
spec.add_dependency "json"
spec.add_dependency "pivotal-tracker"
You have specified development dependency, but call the rake form binary, just put rake gem dependency into usual add_dependency, and remove ::gem call to:
bin/toolshed:
require 'rubygems'
require 'toolshed'
require 'rake'
One again question: for what do you need the binary?
The toolshed.gemspec seems correct. How do you call it? Remove the installed gem with gem uninstall toolshed including binary. Make sure that the bundle install, and then call to bundle exec bin/toolshed.rb is correct after patching the dependencies.
After that generate the gem with gem build toolshed.gemspec, and install the gem with gem install toolshed-0.0.4.gem. Make sure that binary works. Only then publish the gem.

JRuby: Nokogiri 1.6 Failing To Install & Bundler Attempting To Install Already Met Dependency

I am getting an error on jruby (linux) when installing the
"trinidad_diagnostics_extension" gem (though this question is not about trinidad). A chain of dependencies is
generating the error:
"trinidad_diagnostics_extension" depends on "jruby-lint >= 0.3.0"
"jruby-lint >= 0.3.0" in turn depends on "nokogiri >= 1.5.0.beta.4"
Before attempting to install "trinidad_diagnostics_extension", the relevant
part of my gem list looks like this:
$gem list
nokogiri (1.5.9 java)
jruby-lint (0.4.1)
As you can see, the needed dependencies seem already to be met. Nonetheless,
after adding gem 'trinidad_diagnostics_extension' to my Gemfile and then
running jruby -S bundle install, the bundler attempts to install nokogiri
(1.6.0.rc1), and during this installation fails with the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
... bunch of omitted output here
nokogiri.c:42:18: fatal error: util.h: No such file or directory
compilation terminated.
make: *** [nokogiri.o] Error 1
Gem files will remain installed in /home/jg/.rvm/gems/jruby-1.7.3/gems/nokogiri-1.6.0.rc1 for inspection.
Results logged to /home/jg/.rvm/gems/jruby-1.7.3/gems/nokogiri-1.6.0.rc1/ext/nokogiri/gem_make.out
Why is bundler trying to install nokogiri when that dependency is already met?
How can I fix this? Successfully installing nokogiri 1.6 or making the trinidad extension aware that 1.6 does not need to be installed would both be fine solutions.
In case it's relevant I have JRUBY_OPTS=-Xcext.enabled=true
UPDATE
I was able to get it work by first installing the gem outside of bundler:
jruby -S gem install trinidad_diagnostics_extension
And then the bundle command worked fine, since it was already installed. So I got it working by I am still confused by why I had to install it outside of bundler and why that would matter, and would like some insight if anyone has it.
1.6.0.pre1 does not exist for the Java platform, for uninteresting reasons. That said, you should only get prereleases if you specifically ask for them.

How to activate test-unit for RubyMine when developing a library (gem)?

I'm developing a library (a gem) using Ruby 1.9.2. My Gemspec looks like the usual for a gem:
source "http://rubygems.org"
# Specify your gem's dependencies in table_builder.gemspec
gemspec
while in my gemspec I have this line:
s.add_development_dependency "test-unit"
I can see it's being installed and my Gemfile.lock includes it:
PATH
remote: .
specs:
foobar (0.0.1)
GEM
remote: http://rubygems.org/
specs:
test-unit (2.4.5)
PLATFORMS
ruby
DEPENDENCIES
foobar!
test-unit
In my Rakefile I load it with:
require "rubygems"
require "test/unit"
as well as in my test_helper.rb:
require "rubygems"
require "test/unit"
In the command line the tests run and pass, but in RubyMine, whether I run tests or the test rake task, I get this message:
MiniTest framework was detected. It is a limited version of original
Test::Unit framework. RubyMine/IDEA Ruby plugin test runner requires
full-featured version of the framework, otherwise default console
tests reporter will be used instead. Please install 'test-unit' gem
and activate it on runtime.
I'm using RVM, so I checked the SDK is the one I'm using on the command line and test-unit is listed in the list of installed gems.
So, how I activate test-unit in a way that RubyMine likes?
Please refer to help. You need Gemfile with the used gems listed in it for RubyMine to recognize the dependencies.
RubyMine 4.0 (in RC2 at the time of this writing) supports minitest and managed to run the tests out of the box. Way to go JetBrains!

Resources