Could not find diff-lcs when running generate rspec:install - ruby-on-rails

I am a Django guy new to Rails. I'm trying to get rspec-rails working for me but when I run
$ bundle exec rails generate rspec:install
I get..
Could not find diff-lcs-1.2.5 in any of the sources
Run `bundle install` to install missing gems.
Which is bothersome because
diff-lcs (1.2.5)
is alive and well in Gemfile.lock
I have deleted Gemfile.lock and rerun bundle to no avail. I added gem 'diff-lcs' into my Gemfile too.
This is the way I have rspec rails in my gemfile
group :development, :test do
gem 'rspec-rails'
end
Any tips?

Killing the spring processes took care of it for me, as described at https://jasonplayne.com/web-dev/rails-generate-could-not-find-in-any-of-the-sources. I see that use of the spring loader was added in Rails 4.1, but I'm curious about the interaction here and what can be done to address this problem without having to kill spring.

You need to update your bundler:
$ gem update bundler
$ bundle install

Related

How does one upgrade a specific ruby gem to a specific (or the latest) version?

I am trying to upgrade a gem (hydra-derivatives) to version 3.3.2 to see if it solves a bug we are having.
hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.
What I've Tried
bundle update --conservative
hydra-derivatives but that only upgraded hydra-derivatives to
3.2.2 (& we want 3.3.2) and its dependency mini_magick from 4.5.1 to 4.8.0
adding gem 'hydra-derivatives', '~> 3.3.2' but that gave me:
You have requested:
hydra-derivatives ~> 3.3.2
The bundle currently has hydra-derivatives locked at 3.2.1.
Try running `bundle update hydra-derivatives`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
I don't want to run bundle update hydra-derivatives because I don't want it to update a bunch of unnecessary gems and cause problems, hence why I read about --conservative
a. I ran this anyway to test it, and it upgraded target gem to only 3.2.2 and 15 gems in total!
hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.
You can still add this as an explicit dependency in your Gemfile:
# only restrict the version if you know of an incompatibility
gem 'hydra-derivatives' , '~> 3.3'
then run
bundle update hydra-derivatives --conservative
or
bundle update hydra-works --conservative
Remove the hydra-works gem from your Gemfile.
Either remove the gem and its dependencies by hand from the installed gem location or if you have the application in its own Ruby environment using rbenv or rvm run bundle clean --force.
Beware bundle clean --force will remove all of the gems in the Ruby version other than those specified in your Gemfile. If you have other applications that use the same version of Ruby you'll have to reinstall the gems for that application if they are different than what you are using in this application.
Add this to your Gemfile
gem 'hydra-derivatives', '~> 3.3.2'
gem 'hydra-works'
And run bundle install
You should see the correct dependency version now in your Gemfile.lock

Globalid and pg not existing when in gemfile

I am trying to rails server from a cloned repo, I have updated ruby, and rails, followed the rvm process, updated all my gem files, and when I go to serve I receive the message
Could not find globalid-0.3.7 in any of the sources Run bundle
install to install missing gems.
So I do bundle install, then get the error
An error occurred while installing pg (0.20.0), and Bundler cannot
continue. Make sure that gem install pg -v '0.20.0' succeeds before
bundling.
Try to insall that and then get
ERROR: Could not find a valid gem 'globalid-0.3.7' (>= 0) in any
repository ERROR: Possible alternatives: globalid, globalize3
I have googled everything and asked many.
globalid is a dependency of the Rails core gem ActiveJob so it is a required gem to have in your Gemfile.lock. See if it is listed in your Gemfile.lock file. If not you could add it to the top of your gemfile including the version
# gemfile
gem 'globalid', '0.3.7'
Then bundle install. If it works, then you can delete it from your gemfile since it should load automatically when Rails loads (since it is a dependency of Rails' ActiveJob). I've run into a similar issue with another gem and this process worked for me.
It could be a version error. Try using gem 'globalid', '~> 0.4.0' in your gemfile and bundling.

"Bundle install" fails with "thin", and cannot point a different "eventmachine"

I work with Ruby 1.9.3 on Windows.
**I have a trouble to do "bundle install" due to a "thin" gem, for my app.
My original GEMFILE looks like this:
gem "sinatra"
gem "mogli"
gem "json"
gem "httparty"
gem "thin"
Running "bundle install" causes Installing eventmachine (0.12.10) with native extensions which fails. Error is described here: Cannot install thin on windows
Just to mention that "gem install thin" is successful!
Some people on the net, facing this issue, suggested to install
"eventmachine" version 1.0.0.beta.4.1 which I did:
gem list --local shows eventmachine (1.0.0.beta.4.1 x86-mingw32, 1.0.0.beta.2 x86-mingw32)
Yet "bundle install" fails.
In another post: ROR 3.1: Bundle update fails (eventmachine gem)
I followed the advise to specify the exact version of "eventmachine" in GEMFILE, so I edited it like (hopefully I did it right)
gem "sinatra"
gem "mogli"
gem "json"
gem "httparty"
gem "eventmachine" "1.0.0.beta.4.1"
gem "thin"
Now, "bundle install" fails with a different error:
Could not find gem 'eventmachine1.0.0.beta.4.1 (>= 0) ruby' in any of the gem sources listed in your Gemfile.
As I mentioned, this version was successfully installed, and it appears in the local repository.
Please help to make "bundle" "happy" with the right 'eventmachine' version.
Sorry if I missed something basic, or failed to find answer already published.
I think you are missing a comma in this line of the last Gemfile:
gem "eventmachine", "1.0.0.beta.4.1"

Rails 3 bundler updating

I have an application running on thin 1.2.11 behind nginx. I was trying to update my application to the latest version of it's gems using bundle update on a development machine, commiting to git, then running cap deploy. However, thin is giving me the following error:
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.14/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.3.0, but your Gemfile requires rack 1.2.3. Consider using bundle exec. (Gem::LoadError)
On the server I have the following gems installed system wide:
bundler (1.0.14)
daemons (1.1.3)
eventmachine (0.12.10)
rack (1.3.0)
rake (0.9.2)
thin (1.2.11)
My Gemfile for my aplication:
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
gem 'capistrano'
gem 'thin'
gem 'RedCloth'
gem 'will_paginate', '3.0.pre2'
gem 'jquery-rails'
I believe thin is requiring rack 1.3, while something in my Gemfile is requiring rack 1.2.3. Am I managing my gems the wrong way? What is the proper way to manage deployment and proper gem control?
I found using bundle exec thin start works, but I prefer a solution to allow me to use /etc/init.d/thin start.
Please read this: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/ before you tell us what you prefer.
Problem is you prefer to run command from gem installed into system to run application which has it's own dependencies (i.e. rack) specified in Gemfile. You can't have two version of same library loaded at the same time, so it's causing your problem with needing 'bundle exec' in from on every command.
Just do bundle exec at start of your cap scripts and he will pickup gems from bundler.
Often I have same problem if i have in system / currently used gemset newer versions of some gems.
i even have alias called be in shell for bundle exec. New versions of rvm do bundle exec automagicly also :).

Trying to use rspec, but getting an error that rspec-core 2.2.1 has been activated, but my Gemfile requires rspec-core 2.1.0

I've update my gems. I've created a sample Rails app and have the following in my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails'
end
group :test do
gem 'rspec'
gem 'webrat', '0.7.1'
end
However, when I run 'rspec spec/', I get the following message:
/home/jeff/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.7/lib/bundler/runtime.rb:27:in `block in setup':
You have already activated rspec-core 2.2.1, but your Gemfile requires rspec-core 2.1.0.
Consider using bundle exec. (Gem::LoadError)
try using bundle update rspec and bundle update rspec-rails. your Gemfile.lock file, located in the root directory, is probably specifying a version number for each gem.
A combination of Sam Ritchie's and Alexey's solutions helped me here. In the end I had to:
bundle update rspec
bundle update rspec-rails
sudo gem uninstall rspec-mocks
sudo gem uninstall rspec-expectations
sudo gem uninstall rspec-core
(prompts for versions if none are entered)
As Alexey says, use this to see which versions are too high:
gem list rspec
(Would vote for you Alexey, but apparently I don't have enough of a "reputation" on stack.)
I got the same issue right now. to fix it try to:
sudo gem uninstall rspec-core -v 2.2.1
bundle update rspec-core
You may need to do that for other dependent gems (like rspec, rspec-rails etc). Use the command to see the candidates:
gem list rspec
Rails noob here ... I'm following Michael Hartl's brilliant tutorial ... stuck at layouts
Tried changing rspec & webrat versions as mentioned in this post about rspec/webrat errors to no avail.
For rspec v2.1.0 I get the same error as #user338413.
rspec -v returns 2.2.1
dev machine running ubuntu 10.04
resolved....works with rspec 2.2.0 + webrat 0.7.1, although I would still like to know why
This is easily solved:
bundle exec rspec
will force bundler to use the gem version you are requiring for your project, ignoring system-wide settings.
change the version number from 2.1.0 to 2.2.1 in Gemfile.lock

Resources