Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Set up Git and Add Gems

Could not find gem 'capybara (~> 2.1.0) ruby' in the gems available on this machine.

I have the gems noted in my gemfile. I ran bundle install and then when I run bin/rails generate rspec:install, I get the following error.

Could not find gem 'capybara (~> 2.1.0) ruby' in the gems available on this machine. Could not find gem 'capybara (~> 2.1.0) ruby' in the gems available on this machine. Run bundle install to install missing gems.

I looked at all the forum posts about this but nothing has helped. I am using osx and working locally as I want to learn to work on my local machine.

Any help is appreciated. Here is my gem file (stock gemfile list excluded here)

group :development, :test do
  gem 'rspec-rails', '~> 2.0'
end

group :test do
  gem 'capybara', '~> 2.1.0'
end

12 Answers

Hi Mikiah -

I've had problems installing gems in Rails before. Your gem file looks okay. One thing you might try is installing the gem via your terminal:

gem install capybara -v 2.1.0

Hopefully this will install capybara for you.

Good luck!

Ronald

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Yeah, follow what Ronald told you. If it still doesn't work, try running rails generate rspec:install without the bin/.

Thanks for the help. I was able to install the gem using sudo gem install capybara -v 2.1.0 ( I used sudo just to be sure)

I then ran bundle install again

Then I tried rails generate rspec:install and bin/rails generate rspec:install

neither worked. I keep getting the error message

Could not find gem 'capybara (~> 2.1.0) ruby' in the gems available on this machine. Could not find gem 'capybara (~> 2.1.0) ruby' in the gems available on this machine. Run bundle install to install missing gems.

It's weird and can not figure it out. I hate being stuck on something so minor.

Any suggestions?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Try removing the version in the Gemfile:

group :test do
  gem 'capybara'
end

Maybe it will fetch any other available version. Are you on Mac or Linux?

Hey Maciej,

This worked for me!

I'm on a Mac.

I removed the version, reinstalled both versions, ran bundle install and then tried rails generate rspec:install and bin/rails generate rspec:install

neither worked. I keep getting the same error message.

Thanks for any further suggestions. Now I see why I've always tacked on 20% to every timeline an engineer has ever given me.

Mikiah-

If I correctly understand your previous post, you "was able to install the gem using sudo gem install capybara -v 2.1.0," but is getting the the same error when you run the rails generate rspec:install and bin/rails generate rspec:install commands. Hmmm.

The problem may be simple but it's definitely not obvious. Try running the run "gem list" command to see if the capybara gem was actually installed on your system.

Be encouraged, Mikiah, don't let the frustration get your spirits down ... hopefully the solution to this vexing problem will come soon.

Best regards,

Ronald

Interesting, Ronald, the gem is not installed.

*** LOCAL GEMS ***

actionmailer (4.0.0, 3.2.10)
actionpack (4.0.0, 3.2.10)
activemodel (4.0.0, 3.2.10)
activerecord (4.0.0, 3.2.10)
activerecord-deprecated_finders (1.0.3)
activeresource (3.2.10)
activesupport (4.0.0, 3.2.10)
arel (4.0.2, 4.0.0, 3.0.2)
atomic (1.1.14)
bigdecimal (1.2.4)
builder (3.1.4, 3.0.4)
bundler (1.3.5)
bundler-unload (1.0.1)
coffee-rails (4.0.1, 4.0.0, 3.2.2)
coffee-script (2.3.0, 2.2.0)
coffee-script-source (1.8.0, 1.6.3, 1.4.0)
erubis (2.7.0)
execjs (2.2.1, 2.0.1, 1.4.0)
hike (1.2.3, 1.2.1)
i18n (0.6.11, 0.6.5, 0.6.1)
io-console (0.4.2)
jbuilder (1.5.3, 1.5.1)
journey (1.0.4)
jquery-rails (3.1.2, 3.0.4, 2.1.4)
json (1.8.1, 1.8.0, 1.7.6)
mail (2.5.4, 2.4.4)
mime-types (1.25.1, 1.25, 1.19)
minitest (4.7.5)
multi_json (1.10.1, 1.8.0, 1.5.0)
polyglot (0.3.5, 0.3.3)
psych (2.0.5)
rack (1.5.2, 1.4.3)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (4.0.0, 3.2.10)
railties (4.0.0, 3.2.10)
rake (10.3.2, 10.1.0, 10.0.3)
rdoc (4.1.2, 4.1.0, 3.12.2, 3.12)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
sass (3.2.19, 3.2.10, 3.2.5)
sass-rails (4.0.3, 4.0.0, 3.2.5)
sdoc (0.4.1, 0.3.20)
sprockets (2.11.0, 2.10.0, 2.2.2)
sprockets-rails (2.0.1, 2.0.0)
sqlite3 (1.3.9, 1.3.8, 1.3.6)
test-unit (2.1.3.0)
thor (0.19.1, 0.18.1, 0.16.0)
thread_safe (0.3.4, 0.1.3)
tilt (1.4.1, 1.3.3)
treetop (1.4.15, 1.4.12)
turbolinks (2.3.0, 1.3.0)
tzinfo (0.3.41, 0.3.37, 0.3.35)
uglifier (2.5.3, 2.2.1, 1.3.0)

The weird thing is, when I did the sudo gem install (for both the current and v. 2.1.0), it said it was installed.

Mikiahs-MacBook-Pro:odot old$ sudo gem install capybara -v 2.1.0
Password:
Fetching: capybara-2.1.0.gem (100%)
IMPORTANT! Some of the defaults have changed in Capybara 2.1. If you're experiencing failures,
please revert to the old behaviour by setting:

    Capybara.configure do |config|
      config.match = :one
      config.exact_options = true
      config.ignore_hidden_elements = true
      config.visible_text_only = true
    end

If you're migrating from Capybara 1.x, try:

    Capybara.configure do |config|
      config.match = :prefer_exact
      config.ignore_hidden_elements = false
    end

Details here: http://www.elabs.se/blog/60-introducing-capybara-2-1

Successfully installed capybara-2.1.0
Parsing documentation for capybara-2.1.0
Installing ri documentation for capybara-2.1.0
Done installing documentation for capybara after 8 seconds
1 gem installed

So how do I really install the gem?

Crazy!

Hi Mikiah -

Okay, we know capybara is not installed although the system said it was installed. I'm wondering if we're dealing with a path issue here. I don't know, I'm thinking out loud. When you "installed" capybara, were you in your Rails app's directory?

Hopefully others will see this forum post and chime in with possible solutions.

Ronald

I am, that's the weird thing. I'm in the top folder of my rails app.

When I ls, I see:

Mikiahs-MacBook-Pro:odot old$ ls
Gemfile      README.rdoc  app          config       db           log          test         vendor
Gemfile.lock Rakefile     bin          config.ru    lib          public       tmp

Mikkiah -

If you haven't already, try searching and possibly posting this problem on stackoverflow.com I know you indicated you Googled the issue, but try posting to stackoverflow. See what comes back. Can't hurt.

Ronald

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

So I was thinking...maybe you could try use rvm and generate a Gemset, install all the gems there and try using it when in your project.

But the first question is: do you have rvm installed or do you have rbenv installed? I know that having both is harmful, so I don't want you to do stuff that would screw your system. Plus, I don't own a Mac, so I can't test most of this locally.

News: I have both installed.

When I do

rbenv -v

I see

rbenv 0.4.0-98-g13a474c

When I do

rvm -v

I get

Warning! PATH is not properly set up, '/Users/old/.rvm/gems/ruby-2.0.0-p247/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-p247'.

rvm 1.22.9 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Is this a problem? If so, how do I solve it?

Ok, I uninstalled rbenv. How do I use rvm to generate a gemset and use it in the app?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I'm not sure how to install rvm under Mac, you'd have to use an online tutorial for this. Once you have it, follow the documentation of rvm gemsets: http://rvm.io/gemsets

Basically, you will create a 'variable' and define what version of Ruby, Rails and other gems it will use. This will ensure that you have particular gem versions available and maybe this will solve your capybara problem. I have no more solutions for this problem. This is the last thing that comes to my mind.