This blog is talking about how I install metric_fu in a rails project.
firstly, I typed a command "gem install metric_fu", unfortunatlly, I got a error message like this
"ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: metric_fu requires chronic (~> 0.3.0)"
seems that metric_fu can not find the required verion of chronic gem, then I googled chronic, and know that chronic is time parsing tool writen in ruby, the latest version of chronic is 0.6.2.
so how should I solve this problem?
as I know, a gem package is just like a jar file, which contains class files and some manifests files. but a gem package can do one more thing - telling you the name and version of those gems it depends on. so I got a soluation : change the version declaration of chronic in the "dependency declaration file", telling metric_fu to use the latest verion of chronic.
Then I googled again, and a got a import information - people can install gem from source ,
here is the steps:
1. download the correct version of gem source code from code base (github in general)
2. build a gem package from the source.
3. install the gem package you built.
for more detail, you can see here .
Note : step 2 is the key point.
before I build my metric_fu gem, I check a file named
"metric_fu.gemspec", and found out that this is the "dependency description file"
then I find the dependency description of chronic "s.add_dependency("chronic", [">= 0.3.0"])"
modify the version to "0.6.2", run command "gem build metric_fu.gemspec", so I got a metric_fu gem depends on chronic 0.6.2.
finaly, cd to my project directory,
run command "gem install ../gem_repositry/metric_fu.gem",
this time, the metric_fu is installed successfully.
Hope this information is helpful for you.
Update: this is not a good pratice.
you can install a old version of chronic manually, and then install metric_fu 2.1.1.
and I met another problem when running metric_fu in ruby 1.9.2 with syntax 1.0 - "invalid UTF8 charater sequence", you can find the issue here .
my soluation is just like Jscruggs said . here is my configuration code:
MetricFu::Configuration.run do |config| config.syntax_highlighting = false end