Getting gcal4ruby gem to work - ruby-on-rails

I'm trying to create a RoR web application that allows people to connect to their accounts to google calendar.
I found a gem called gcal4ruby that seemed to do the right things based on looking at sample code and its documentation.
I ran gem install and the cmd claimed the installation was ok.
However, when I added the gem to my gemfile then try to run the server again I get:
Could not find 'gcal4ruby (= 0.0.5, runtime)' in any of the gem sources
Try running 'bundle install'.
Then I tried bundle install which basically gets me the message above and a line:
Fetching source index for http://rubygems.org/
Could not find 'gcal4ruby (= 0.0.5, runtime)' in any of the gem sources
Yet when I type in "gem list -d g", gcal4ruby (0.5.5) appears on the list.
I've tried adding in requires and includes but that just gets me uninitialized constant errors.
Other details that may be relevant:
ruby 1.8.7
rails 3.0.1
gem check --alien returns:
mysql-2.8.1-x86-mingw32 has 1 problems
.require_paths:
Extra file
*Note: This doesn't seem to negatively impact me when I'm doing anything though.
If possible, please supply tutorials/sites with samples of working code.
Cheers,
Zigu

Could you post your gemfile please?
I'm guessing your Gemfile reads
gem 'gcal4ruby', '0.0.5'
which means it will only look for that specific verison. So there are two ways to fix this.
Change it to minimum version syntax
gem 'gcal4ruby', '>= 0.0.5'
Change to correct specific gem version
gem 'gcal4ruby', '0.5.5'
Hope that helps

Related

Ruby - Install Sinatra gem error on ruby mine

I'm working on a new project in Ruby, which I'm learning, and I need to install Sinatra gem and I'm getting the following error:
"Following gems were not installed: sinatra-sinatra (0.10.1): While
executing gem ... (Gem::UnsatisfiableDependencyError)
Unable to resolve dependency: 'sinatra-sinatra (= 0.10.1)' requires 'rack (>= 1.0)'"
Currently I'm using, RubyMine (Windows). Any help would be appreciated.
Thanks
The problem is not RubyMine, but some other dependency conflict in your app. The gem sinatra-sinatra requires Rack 1.0, there is probably another gem in your Gemfile that requires a greater or different version of the same gem.
Actually, I believe your problem can easily be fixed by using the proper gem. sinatra-sinatra is a very old gem, if you want to use the Sinatra framework the correct gem is sinatra. Update your Gemfile accordingly.
In you machine
gem install sinatra-sinatra
Check you Gemfile
gem 'sinatra-sinatra', '~> 0.10.1'
Delete the Gemfile.lock and bundle its once again.

Rails 4 full page caching is not working

Rails4 full page caching is removed and extracted as gem and I am using that gem called 'actionpack-page_caching', but it is not working. It is throwing undefined method `caches_page' for controller class. I tried a lot to debug the issue but no relevant documentation for the same. Please help me out with the solutions.
Even though your bundle command says you have those 2 gems installed
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
Try to delete the Gemfile.lock file and run the bundlecommand again.
And my output on the second run was correct:
Installing actionpack-action_caching (1.1.0)
Installing actionpack-page_caching (1.0.2)
And I was able to use caches_page.

"Invalid gemspec" messages during "bundle install" of factory girl (rails 3.1 and ruby 1.9.2p290)

Note:
I asked this question when I got unexpected messages when doing bundle install with the factory_girl gem using Ubuntu 11.10. Being a noob I had ... and still have ... no idea what was going on. The update below attempts to outline what I did to eventually get rid of the messages. I am leaving the question around with a slightly more pertinent title line in case it might be of use to someone else.
I look at Factory Girl's README.md and I see:
Install
gem install factory_girl
or add the following line to Gemfile:
gem 'factory_girl'
and run bundle install from your shell.
Supported Ruby versions
The Factory Girl 3.x series supports Ruby 1.9.x.
For older versions of Ruby, please use the Factory Girl 2.x series.
Since I am currently using
Rails 3.1.0 and
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
I add gem 'factory_girl' to my Gemfile and do bundle update.
But then continuing on I open the Getting Started.md file and read
Update Your Gemfile
If you're using Rails, you'll need to change
the required version of factory_girl_rails:
gem "factory_girl_rails", "~> 2.0"
If you're not using Rails, you'll just have to
change the required version of factory_girl:
gem "factory_girl", "~> 3.0"
Once your Gemfile is updated, you'll want to update your bundle.
OK, fine. I remove gem 'factory_girl' from my Gemfile and instead add
gem "factory_girl_rails", "~> 2.0".
I then try bundle update once again. This time, no joy.
$bundle install
Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/
factory_girl_rails-2.0.0.gemspec]: Illformed requirement
["# 3.0.7"]
Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/
factory_girl_rails-2.0.0.gemspec]: Illformed requirement
["# 3.0.7"]
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using ZenTest (4.7.0)
... a bunch of "Using" lines omitted for brevity ...
Using deepopenstruct (0.1.2)
Using factory_girl (3.0.0)
Installing factory_girl_rails (2.0.0) Invalid gemspec in
[/usr/local/lib/ruby/gems/1.9.1/specifications/factory_girl_rails-2.0.0.gemspec]:
Illformed requirement ["# 3.0.7"]
Using haml (3.1.4)
Using jquery-rails (1.0.19)
... a bunch of "Using" lines omitted for brevity ...
Using uglifier (1.2.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a
bundled gem is installed.
So now I'm wondering (1) why following the instructions in the READMEs have apparently not worked and (2) what should I do to my Gemfile in order to get Factory Girl smiling and productive?
Update
While getting error messages which I do not understand is frustrating, getting rid of them but not really being sure what I did to, err, "fix" things is also less special. Oh, well.
In all honesty, though I have been using bundle I had no idea what the difference was between gem, rvm, and bundle nor did I really understand what each command is supposed to do. I think this blog entry I found via Google helped somewhat with that:
RVM and Bundler in Five Seconds
Thinking that rvm and bundle are supposed to automate the management of a group of gems while gem just manages gems, I looked at the gem commands.
I tried gem check which IIRC did nothing. I then tried gem cleanup which came back with a long list of gems it wanted to uninstall. Trusting that I could (probably) get back to where I needed to be by using bundle install, I let it do the uninstalls. (Though I had to use sudo gem cleanup because I lacked write permission to some of the directories involved).
After doing this gem check and gem cleanup came back clean. However, bundle check returned:
The following gems are missing
* activesupport (3.1.0)
* activemodel (3.1.0)
* rack-cache (1.0.3)
* actionpack (3.1.0)
Install missing gems with `bundle install`
So I did both bundle install followed by (why not?) bundle update. This installed the gems listed above with no problems. In particular, this time I did not get the Invalid gemspec or any other error messages. (Hurrah!)
Of course, bundle update did nothing as, frankly, I was expecting it to do.
So while I'm still not sure what happened, the original reason for my question has been kinda, sorta solved.
I'll leave this question unanswered for a week or so to see if anyone else wants to contribute any comments. After that if no one else provides a more informative answer, I guess I'll just "answer" this question myself to close it out.
Thanks to all who helped nudge me towards a cleaner set of gems.
I ran into pretty much the same problem when trying to install the factory_girl_rails gem and was able to resolve it by removing the offending specifications file and then running
gem update --system
followed by
bundle install
There is apparently some errors generated in the gemspec.
Open it and remove the shitty bits!
personally I did it using vim like so:
vim ~/.rvm/gems/ruby-1.8.7-p357/specifications/factory_girl_rails-1.7.0.gemspec
:%s/".*YAML.*\ /"/
:wq
then re bundle
and the problem should be solved !
With ruby 1.8.7 and factory_girl_rails you can pin the version of factory_girl to 2.6 and let bundler do the rest.
gem 'factory_girl', '~> 2.6'
gem "factory_girl_rails"
Worked for me.
There is no point that I can see in keeping this question open any longer. While I never did clearly understand why I was getting Invalid gemspec, the steps which are listed in my update to my question "solved" that "problem".
It would be nice if there was a way to simply close a question as "An answer is no longer a priority for me" or even simply "I've moved on". But there isn't. This "answer" will at least take this question off the list of things to still be looked at.

bundle install failing for 'letter-opener' gem in rails

I am trying to use Ryan Bates 'letter-opener' gem as described in Episode #104 (and in many other places on the web) In every instance I have found, it appears that users are simply including the gem in their Gem file with the traditional ruby gems gemsource. When I attempt this, rails fails to find the gem. I must be doing something wrong, but what?
source "http://rubygems.org"
...
gem "letter-opener", group: :development
Then I type
$ bundle install
and I receive the following message:
Fetching source index for http://rubygems.org/
Could not find gem 'letter-opener (>= 0) x86-mingw32' in any of the gem sources listed in > your Gemfile.
Thanks for the help!
It's a common error to mistype a compound-word rubygem with an underscore ('_') instead of a hyphon ('-') or viceversa.
If you ever find this problem, you can go to http://rubygems.org, and search for the gem's name.
In this case, searching for letter opener returns this result, which suggests that the gem is actually called letter_opener
use gem 'letter_opener'instead of gem 'letter-opener'.

Installing gems tutorial

Is there anywhere that there are step by step instructions on how to install gems?
My google-fu is weak and those that I could find did not resolve my error.
My errors are detailed here:
Getting gcal4ruby gem to work
Basically my error sums up as:
gem installs properly and is detectable by,
but whenever I try to reference it in my application it just says:
Could not find 'gcal4ruby (= 0.0.5, runtime)' in any of the gem sources Try running 'bundle install'.
(* I tried bundle install -> no help *)
Your error states:
Could not find 'gcal4ruby (= 0.0.5, runtime)' in any of the gem sources Try running 'bundle install'.
It's looking for 0.0.5 of gcal4ruby, which you don't have installed, rather you're saying yourself that the gem list -d shows:
gcal4ruby (0.5.5)
Which is not the correct version. I would recommend attempting to discover what's trying to require this older version of gcal4ruby. I think it's in your Gemfile, but I have been known to be wrong occasionally.
If this answer doesn't solve your question, then please attach the errors you're getting and your Gemfile to your question.
As a guess, you are using rails 3? Rails 3 uses a project called bundler for dependencies, so instead of installing the gem in your system ruby, add gem 'gcal4ruby to the Gemfile in the root of your app. after that, a bundle install will install the gem locally into your app.
Bundler means that rails 3 apps have their gems completely isolated from the system gems. Even if the gem is installed in the system, it will not be accessible in the app.

Resources