When I try to run some rspec test cases I'm getting this error
I'm using linux rails 3.0.0, ruby 1.9.2 (with RVM)
config/boot.rb:8: uninitialized constant Bundler (NameError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' ..
But when do a gem list , it shows both
builder (2.1.2)
bundler (1.0.10)
so what can be the problem?
Just update your bundler, in latest version such issue is resolved.
'gem install bundler'
and then 'bundler install'
If you find again error, then delete GEM.lock file, then run bundler install. It may resolve the issue.
Related
I am trying to use rails-erd. The last time I used it was in February and worked fine
I tried using erd and bundle exec erd
I am getting this error.. I have rails 4 in another project, but in this project I use rails 3.2.15 in the gem file
Loading application in 'my_app'...
WARN: Unresolved specs during Gem::Specification.reset:
activerecord (>= 3.0)
i18n (>= 0.6.4, ~> 0.6)
multi_json (~> 1.3)
tzinfo (~> 0.3.37)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Failed: Gem::LoadError: You have already activated activesupport 4.0.0, but your Gemfile requires activesupport 3.2.15. Using bundle exec may solve this.
What does this mean and how do I solve this?
The error shows that you have already activated activesupport 4.0.0 but in your gemfile.lock file the version of the activesupport is 3.2.15.
So simply delete the gemfile.lock file and again bundle install
It will take the latest version of activesupportor, or either you can change the version manually.
In the Gemfile of the app specify the version of Rails if you haven't done so:
gem 'rails', '3.2.15'
Run bundle install then try running the script again using bundle exec.
If it still doesn't work try uninstalling rails 4 and then running it.
gem uninstall rails
Ideally if you're executing your script with bundle exec it always execute the script in the context of the current bundle using the Gemfile.
I am working on rails, suddenly rails server stops working. It's working fine and I have used following command [platform windows 7]
gem install -v=2.3.5 rails
And when I use rails s, it's giving the following error:
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/base.rb:90:in `<class:Base>'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/base.rb:85:in `<module:Generator>'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/base.rb:48:in `<module:Rails>'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/base.rb:6:in `<top (required)>'
from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator.rb:34:in `<top (required)>'
from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/bin/rails:14:in `<top (required)>'
from c:/Ruby193/bin/rails:23:in `load'
from c:/Ruby193/bin/rails:23:in `<main>'
$ rails -v
Rails 2.3.5
$ ruby -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
I had the same problem, but it was the result of having the gem rmagick.
I ran the following:
gem uninstall rmagick
gem cleanup
And then re-ran bundle in my stack and it worked for me again.
I have solved this issue. Use following command and problem gone
gem install rails
This will install updated rails and all thing working find again.
Running bundle exec rails s worked for me.
My project was using Rails 3.x but when I ran rails -v I got 2.3.17 which is the version used by a project I worked on just before. Somehow installing this version must have be set as "default".
Could someone explain this ?
if you are using latest version of rails 3 or rails 4 then use class_attributes instead of write_inheritable_attribute, i.e.
class_attribute :variable_name
self.variable_name = value
instead of
write_inheritable_attribute(:variable_name, value)
I had this issue, and it happens that I was in using the wrong ruby and gemset in rvm.
(#jeremy-f and #alex-villa are on the right track to identifying the problem itself.)
The problem here is that the rails ... command in Rails version 2 is a generator, equivalent to rails new ... in Rails 3+. So rails s is a Rails 2 command to generate a new Rails 2 app called "s" (whereas most of us when we write rails s intend the Rails 3 usage, i.e. start a server!)
If you install a gem, it will usually install its binary in the path, so you should be able to cause this error by doing gem install rails -v 2.3.15 then rails s as the OP says.
Three ways to fix it:
gem install rails to install a newer version of Rails (you may have to specify a version >= 3.0)
Run the app with bundle exec rails s (only if you have Rails 3 in your Gemfile)
The usual way to run a Rails 2 project is simply script/server
I've just tried to update to Rails 3.1.3 using RVM with the following commands:
rvm install ruby-1.9.3-p0
rvm --default use ruby-1.9.3-p0
If I query the current version or ruby:
ruby -v
I get the correct version: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
Then to update the gems:
gem update --system
This gives me version 1.8.24
I then create my gemset and set it as my default:
rvm ruby-1.9.3-p0#rails313 --create --default
and finally install the Rails gem:
gem install rails
When I query the version of rails:
rails -v
I get Rails 3.0.11 ... my old version of Rails
If I try to start my Rails server
rails s
I get a huge error:
.rvm/gems/ruby-1.9.3-p0#rails313/gems/activesupport-3.0.11/lib/active_support dependencies.rb:239:in `require': dlopen(/Users/lss_dev/.rvm/gems/ruby-1.9.3-p0#rails313/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
With a lot of complaints about dependencies.
My gemfile.lock does contain the following block:
rails (3.0.11)
actionmailer (= 3.0.11)
actionpack (= 3.0.11)
activerecord (= 3.0.11)
activeresource (= 3.0.11)
activesupport (= 3.0.11)
bundler (~> 1.0)
railties (= 3.0.11)
Does this have something to do with it or should I even be touching the gemfile.lock file??
I'm using rvm version 1.10.0, any help would be appreciated
To answer my own (extended) question...
Trashing the gemfile.lock file allowed me to just run
bundle install
ensuring that I had my Rails gem set to the correct version (3.1.3), which worked. The issue that I was running into then was when I started my rails server I got the following browser error
undefined method `consider_all_requests_local' for ActionController::Base:Class
Initially I thought this was due to some routing changes in Rails 3.1.* As it turned out in my application_controller.rb file I was dealing with 404 errors and had the following block:
unless ActionController::Base.consider_all_requests_local
rescue_from Exception, :with => :render_404
end
ActionController::Base.consider_all_requests_local
Is now deprecated and substituting in:
Rails.application.config.consider_all_requests_local
Did the trick.
Thank you for your help and I hope this helps someone in the future
You may have to swap the version of rvm / ruby and then install.
This may be of use: https://rvm.io/gemsets/basics/
I get an error after issuing the git push heroku command. This initially looked like something to be solved by using the heroku config command to bundle without the development:test gems. However, I used that command as discussed in this similar writeup [ Heroku's trying to install development gems even after I've told it not to ] and it still doesn't work.
The line "Using --without development:test" in the push message below seems to indicate the BUNDLE_WITHOUT config command worked, so maybe this is a gemfile or other issue?
Thanks!
$ git push heroku
Counting objects: 64, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (42/42), done.
Writing objects: 100% (48/48), 6.03 KiB, done.
Total 48 (delta 15), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for http://rubygems.org/
Installing rake (0.8.7)
Installing ZenTest (4.5.0)
Installing abstract (1.0.0)
Installing activesupport (3.0.3)
Installing builder (2.1.2)
Installing i18n (0.5.0)
Installing activemodel (3.0.3)
Installing erubis (2.6.6)
Installing rack (1.2.2)
Installing rack-mount (0.6.14)
Installing rack-test (0.5.7)
Installing tzinfo (0.3.25)
Installing actionpack (3.0.3)
Installing mime-types (1.16)
Installing polyglot (0.3.1)
Installing treetop (1.4.9)
Installing mail (2.2.15)
Installing actionmailer (3.0.3)
Installing arel (2.0.9)
Installing activerecord (3.0.3)
Installing activeresource (3.0.3)
Installing autotest (4.4.6)
Installing sys-uname (0.8.5) with native extensions
Installing autotest-fsevent (0.2.5) with native extensions /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/usr/ruby1.8.7/bin/ruby extconf.rb
extconf.rb:19: Only Darwin (Mac OS X) systems are supported (RuntimeError)
Gem files will remain installed in /disk1/tmp/build_258oz7hi5972n/.bundle/gems/ruby/1.8/gems/autotest-fsevent-0.2.5 for inspection.
Results logged to /disk1/tmp/build_258oz7hi5972n/.bundle/gems/ruby/1.8/gems/autotest-fsevent-0.2.5/ext/fsevent/gem_make.out
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each'
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `run'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `send'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/bin/bundle:13
from /usr/ruby1.8.7/bin/bundle:19:in `load'
from /usr/ruby1.8.7/bin/bundle:19
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
error: hooks/pre-receive exited with error code 1
To git#heroku.com:blooming-mountain-199.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:blooming-mountain-199.git'
Gemfile...
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'sqlite3', '1.3.3', :require => 'sqlite3'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
gem "nokogiri"
gem "geokit"
gem "rack", "~>1.1"
group :development, :test do
gem 'rspec-rails', '2.5.0'
gem 'annotate-models', '1.0.4'
gem 'faker', '0.3.1'
gem 'autotest-fsevent' if RUBY_PLATFORM =~ /darwin/
gem 'rspec', '2.5.0'
gem 'webrat', '0.7.1'
gem 'spork', '0.9.0.rc4'
gem 'factory_girl_rails', '1.0'
gem 'ZenTest'
gem 'autotest'
gem 'autotest-rails'
gem 'autotest-growl'
end
Well, the problem is clearly with the autotest-fsevent getting loaded when you push to Heroku, which is not Darwin-based. Although you do have a conditional following the gem 'autotest-fsevent' statement, the gem is still trying to load when you deploy to Heroku. There are two likely causes for this.
The first, is that another gem is requiring it. If nothing else, autotest-growl should also be Darwin-only. I'm not sure these are related, but I'd still double-check.
The next issue is to make sure that Gemfile.lock isn't getting pushed. If you last ran bundle install on Darwin, it's possible that the gem got locked into the dependencies that way. git rm Gemfile.lock before you commit and push to Heroku.
Finally, my favored solution is not to use autotest. I'm not sure if that's an option for you, but I found it to be annoying when I did use it I use RSpec and Cucumber. I realize this last suggestion is a non-answer, but I don't like including platform-dependent gems even in testing, just because when you go to staging, little annoyances like this have a tendency of cropping up.
I'm not sure why Rails Tutorial is still using ZenTest and autotest, I don't know anyone who does... that might be changing, a friend went to the Rails Tutorial session at RailsConf and said Michael was actually noting errata during the tutorial, so maybe it'll be different in a future version.
As a final note, out of curiosity, if you are on OS X, how did you install Ruby? It's in a very odd place.
On Windows 7 with Ruby 1.9.2-p180 and Rails 3.0.5 installed, if I
rails new trytry
cd trytry
bundle install
it will show
C:\ror\trytry>bundle install
c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/ui.rb:46:in `<class:UI>': uninitialized constant Gem::SilentUI (NameError)
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/ui.rb:2:in `<module:Bundler>'
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/ui.rb:1:in `<top (required)>'
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/cli.rb:17:in `initialize'
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/vendor/thor.rb:246:in `new'
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/vendor/thor.rb:246:in `dispatch'
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/vendor/thor/base.rb:389:in `start'
from c:/ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/bin/bundle:13:in `<top (required)>'
from c:/Ruby192/bin/bundle:19:in `load'
from c:/Ruby192/bin/bundle:19:in `<main>
only after a
gem install bundler
or probably a
gem update bundler
then the bundle install will work. So looks like the Rails 3.0.5 needs a newer bundler which was not listed correctly in the dependency? Otherwise when I gem install rails for 3.0.5, it should have updated bundler as well, is that right?
You've got an older version of Bundler installed, you will need to run gem install bundler to update it to the latest version.
Rails depends on a version of Bundler matching the dependency version of ~> 1.0. If you've got a version of Bundler installed, such as 1.0.0, the process of gem install rails sees this dependency is matched already and so won't update Bundler. Therefore, you need to run gem install bundler to update it to the latest version.