I am trying to install cucumber on rails 2.3.11 (gem -v = 1.6.2) with the following Gemfile
group :test do
gem 'fabrication'
gem 'cucumber'
gem 'cucumber-rails'
end
Bundle install is successful, but I can't find the 'cucumber' generator.
bundle exec script/generate cucumber
/Users/Tim/.rvm/gems/ree-1.8.7-2011.03#new_horizons/gems/rails-2.3.11/lib/rails_generator/lookup.rb:212:Warning: Gem::cache is deprecated and will be removed on or after August 2011. Use Gem::source_index.
/Users/Tim/.rvm/gems/ree-1.8.7-2011.03#new_horizons/gems/rails-2.3.11/lib/rails_generator/lookup.rb:234:Warning: Gem::cache is deprecated and will be removed on or after August 2011. Use Gem::source_index.
Couldn't find 'cucumber' generator
Any thoughts greatly appreciated. I am running:
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03
tim
When you're running the generators they are actually running in the development environment, not test. Therefore these dependencies won't be loaded. Put them in a group like this instead:
group :development, :test do
gem 'cucumber-rails'
...
end
Secondly, you don't need to specify cucumber as well as cucumber-rails, as the cucumber gem is a dependency of the cucumber-rails gem and will be automatically included.
According to the cucumber-rails documentation, the generate command should be cucumber:install, not just cucumber. It also says it's for Rails 3, not sure if that's true though.
First thought is to upgrade your ruby version. In the long run that will solve more problems as newer gems are becoming dependent on ruby 1.9.2. Install RVM and use that to manage your different ruby versions and gem sets.
The second thing is to do what the error is saying.
gem sources
That will show you which souces and gems you have. Something like this:
*** CURRENT SOURCES ***
http://rubygems.org/
If you know where you specific gem is being hosted then you can add those sources to the top of your bundler file. Usually all you need is http://rubygems.org/.
But you can also add it directly to your sources with this:
gem sources:add `http://rubygems.org/`
Related
I've been attempting to make a start on learning Ruby/rspec. I read that rspec is now broken for Windows so an early version (2.14.1) should be installed instead. I started on testfirst's learn Ruby but kept getting errors whenever I attempted the "rake" task. I checked my rspec version and apparently I'm running 2.14.8. I thought maybe that was why I was getting some errors. So I typed into git "gem uninstall rspec" but it then said version 2.14.1 was uninstalled, not .8. So I checked to see if there were any versions of rspec installed on my computer and it says that 2.14.8 is still installed... now it won't let me uninstall it, even though I typed in "gem uninstall rspec -v 2.14.8."
I also tried to check the contents of version 2.14.8, but it couldn't find gem 'rspec' in default gem paths.
It's as if I had two versions of rpec on my laptop... how do I get rid of the .8 version?
If gem uninstall rspec -v 2.14.8 did not work for you. Try cleaning up all the rspec version from your computer first by running:
gem cleanup rspec
Then, install the required version again.
Update:
Try:
gem uninstall -Iax rspec
If doesn't work, then try and remove the executables as well:
gem uninstall rspec-core
Where did you hear that RSpec is broken on Windows? AFAIK the current version (3.3.2) works just fine.
If you are going to learn Ruby and RSpec, you should also learn about using Rubygems and Bundler, since many projects rely on them. Install Bundler with:
gem install bundler
Create a new folder and CD into it, and then:
bundle init
This creates a file named "Gemfile" in the folder. This allows Bundler to manage the versions of gems used within your project. Edit the Gemfile and add this line:
gem 'rspec', '~> 3'
This tells Bundler that your project requires RSpec 3, and to install the latest version. Save the Gemfile, and then do:
bundle install
Bundler will install the RSpec gems and create a Gemfile.lock file that details the gem dependencies. To verify that the right version is installed:
rspec --version # => 3.3.2 (or whatever is the latest)
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.
I am trying to connect Rails to Sql Server so I need to use an Sql Server adaptor. I installed it by downloading the adaptor locally from github.com/Desarrollo-CeSPI/activerecord-sqlserver-adapter.git. After that I did: gem build activerecord-sqlserver-adapter.gemspec in the directory where I had the spec file, followed by gem install <name of gem that was just built>.
After that, I added this line in the gemfile:
gem 'activerecord-sqlserver-adapter', :path => 'downloads/activerecord-sqlserver-adapter-master\activerecord-sqlserver-adapter-master' , then I ran a bundle install from the project root.
The error is:
Bundler could not find compatible versions for gem "activerecord": In
Gemfile: rails <=4.1.6> x86-mingw32 depends on activerecord <=4.1.6>
x86-mingw32
activerecord-sqlserver-adapter <>=0> x86-mingw32 depends on
activerecord <4.0.0>
What is strange is rails -v doesn't return the rails version although I just installed it.
Instead it throws:
Could not find gem 'tzinfo-data <>=0> x86-mingw32 in the gems available on this machine
Run bundle install to install missing gems
I should specify we are compulsed to use proxies at work
Every few month I keep checking to see if the Sql Server connection is improved/easier to perform with Rails without adaptors and such, because I want to use Sql Server instead of PostgreSQL. No luck so far. Any help is much appreciated. Thanks
It looks like the gem that you are using only supports until rails 4.0.0 (the gemspec forces to be this version).
You might try to use that rails version to see what's going on.
To do so, in your Gemfile.rb you can try this:
gem 'rails', '4.0.0'
gem 'activerecord-sqlserver-adapter', git: 'https://github.com/Desarrollo-CeSPI/activerecord-sqlserver-adapter.git'
and then run
bundle update rails # to force using the rails version specified in the gemfile
and then run
bundle install
BUT
The gem that you are using has not been updated since 22nd August 2013, so I would not expect it work.
The gem that you are using is a fork of the original project located at https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
If you don't have anything to do with Desarrollo-CeSPI, then you should use the official gem to avoid some problems, for instance that the gem is not maintained anymore.
I am having a problem getting an old Ruby on Rails 2 app that hasn't worked in a year to work.
I'm trying to run rake test:functionals in the root of my project directory, but am getting undefined method 'name' for "SystemTimer":String.
I've pasted everything that I believe relevant to the problem here:
http://pastebin.com/NgBvystZ
Also, when I run rake itself, I get
Errors running test:units!
Not sure how to debug that.
I have copied and pasted everything that I think would be useful to understanding this problem. Your time is greatly appreciated. Thank you.
This is an incompatibility between versions of RubyGems greater than 1.3.7 and versions of Rails less than 2.3.12. There are a few ways to solve this.
Use Bundler
Bundler is easy to install, fixes this problem, and has a number of other advantages as well. I highly recommend it.
Upgrade to Rails 2.3.12 or higher
Rails 2.3.12 fixed compatibility issues with RubyGems 1.8.5 (see release report).
Downgrade to RubyGems 1.3.7
I would not recommended this unless you have no other choice. Use this command: gem update --system 1.3.7. Also, version 1.7.2 has partial compatibility (it will run, but freezing gems will fail and there are likely other issues).
I chanced upon this thread, because I got the following error when migrating some Radiant 0.9.1 installations to a new server:
undefined method `name' for "RedCloth":String
(3) The compromising solution: I haven't tested this personally, but I hear that rails 2.3 with bundler is compatible with the latest rubygems. If you're interested in this solution, see http://gembundler.com/rails23.html for getting bundler to work under rails 2.3.
For me solution 3 was the only option, since we had other apps needing the latest rubygems on the system.
Just install bundler and follow thes steps on this page:
http://gembundler.com/rails23.html
And put this in a file called "Gemfile" in the app root:
source :gemcutter
gem "radiant", "0.9.1"
gem "sanitize"
gem "fastercsv"
gem "rmagick"
gem "rack", "~> 1.1.0"
gem "rake", ">= 0.8.3"
gem "RedCloth", ">= 4.0.0"
gem "will_paginate", "~> 2.3.11"
gem "mysql"
This is just my example. Start with only the first 2 lines, run bundle update and reload the page to see what else you might be missing.
Thank you Ben!
have ruby 1.8.7, gem 1.3.7 and rails 3.0.6. I wanted to add xmpp4r to my project, but i got error just i require this gem. I'm install this gem using gem install xmpp4r. Installation seems successful.But, why error then appear?
P.S. if in console enter the irb and execute require "xmpp4r" result will be true.
P.S.S. OS is Fedora
Rails 3 uses Bundler to manage gem dependencies. When you start a rails 3 application, bundler sets up the require path to only include those gems you have specified in your Gemfile file, and their dependencies; it's not enough to just have the gem installed on your system.
In order to get this working, simply add this line to your Gemfile:
gem 'xmpp4r'