Error loading rubygems - ruby-on-rails

During an operation (rspec related) that required loading rubygems (from config/boot.rb file) I got the following error message:
~/config/boot.rb:1:in `require': no such file to load -- rubygems (LoadError)
~/config/boot.rb:1
from ~/config/application.rb:1:in `require'
from ~/config/application.rb:1
from ~/config/environment.rb:2:in `require'
from ~/config/environment.rb:2
from ~/spec/spec_helper.rb:3:in `require'
from ~/spec/spec_helper.rb:3
from ~/spec/models/user_spec.rb:1:in `require'
from ~/spec/models/user_spec.rb:1
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load'
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load_files'
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `each'
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `load_files'
from /usr/lib/ruby/1.8/spec/runner/options.rb:132:in `run_examples'
from /usr/lib/ruby/1.8/spec/runner/command_line.rb:9:in `run'
from /usr/bin/spec:3
I looked for this error on SO and found the following topics:
ruby gem not found although it is installed and
no such file to load -- rubygems (LoadError)
However they both mentionned that the problem could come from the existance of multiple versions of ruby on the machine. Actually that was the case, so I decided to run a fresh installation of ruby and rails using RVM. But I still have the same problem!
Additional information:
which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/ruby
which rails
/usr/local/rvm/gems/ruby-1.9.2-p136/bin/rails
which gem
/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/gem
gem --version
1.5.0
ls /usr/lib/ruby
1.8 1.9.1 gems
Any idea?

So I apparently solved my problem by using the command rspec instead of spec. If someone can explain what is actually going on behind the scene, it would be great!
amokrane#san-francisco ~/Documents/prog/web/learning_rails/forecaster/spec $ spec models/user_spec.rb
/home/amokrane/Documents/prog/web/learning_rails/forecaster/config/boot.rb:1:in `require': no such file to load -- rubygems (LoadError)
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/boot.rb:1
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/application.rb:1:in `require'
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/application.rb:1
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/environment.rb:2:in `require'
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/environment.rb:2
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/spec_helper.rb:3:in `require'
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/spec_helper.rb:3
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/models/user_spec.rb:1:in `require'
from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/models/user_spec.rb:1
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load'
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load_files'
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `each'
from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `load_files'
from /usr/lib/ruby/1.8/spec/runner/options.rb:132:in `run_examples'
from /usr/lib/ruby/1.8/spec/runner/command_line.rb:9:in `run'
from /usr/bin/spec:3
amokrane#san-francisco ~/Documents/prog/web/learning_rails/forecaster/spec $ rspec models/weather_spec.rb
F
Failures:
1) Weather should be valid
Failure/Error: #weather = Weather.new
ActiveRecord::StatementInvalid:
Could not find table 'weathers'
# ./models/weather_spec.rb:6:in `new'
# ./models/weather_spec.rb:6:in `block (2 levels) in <top (required)>'
Finished in 0.11124 seconds
1 example, 1 failure

Related

Ruby1.8 Rails2.3 ./script/server producing error

I have been assigned a projected that was written in Ruby1.8 and Rails2.3. We can't upgrade at the moment. I have successfully installed ruby and rails and installed all needed gems for the project on a ubuntu machine. I have received success messages while installing everything.
However, when I run the command ./script/server I received the output:
/var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require': no such file to load -- sentry (MissingSourceFile)
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /home/robotmaster/Documents/Source/agile/config/initializers/sentry.rb:1
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:171:in `load_without_new_constant_marking'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:171:in `load'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:171:in `load'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:622:in `load_application_initializers'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:621:in `each'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:621:in `load_application_initializers'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:176:in `process'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:113:in `send'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:113:in `run'
from /home/robotmaster/Documents/Source/agile/config/environment.rb:42
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/commands/server.rb:84
from ./script/server:4:in `require'
from ./script/server:4
I am new to the Rails and would appreciate any help with this error message. Thanks
The key to the issue is here:
sentry (MissingSourceFile)
I'm really not familiar with that particular file (and Rail 2.3 is several major revisions behind...) but it indicates to me that there's something incomplete about your Gem set.
gem update
This would be my first attempt. Verify that all of the referenced gems in your Gemfile are present on the system. If at all possible, I'd really look to upgrade to at least Rail 3, preferably 4.
EDIT:
Reading this again, why are you executing ./script/server? You should be executing:
rails s

Why won't Rails' console start or make new apps?

A few days ago I updated my gems because things weren't running so fine, so I went back to 1.4.2. Since then I'm getting all kind of weird errors.
I'm using Ruby 2.0.0p247, Rails 4.0 and Ubuntu.
If I try to start a new app using rails new eraseme, everything goes fine until it's time to do bundle install. The output is:
run bundle install
/usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/generators/app_base.rb:270:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/generators/app_base.rb:270:in `bundle_command'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/generators/app_base.rb:277:in `run_bundle'
from (eval):1:in `run_bundle'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `block in invoke_all'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `each'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `map'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `invoke_all'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/group.rb:233:in `dispatch'
from /usr/local/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/application.rb:43:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/cli.rb:15:in `require'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/cli.rb:15:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/bin/rails:9:in `require'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/bin/rails:9:in `<top (required)>'
from /usr/local/bin/rails:23:in `load'
from /usr/local/bin/rails:23:in `<main>'
If I try to open the console, I get:
>> bundle exec rails console
Loading development environment (Rails 4.0.0)
/usr/local/lib/ruby/2.0.0/irb/locale.rb:150:in `block in search_file': undefined method `try_activate' for Gem:Module (NoMethodError)
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:158:in `block in each_localized_path'
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:167:in `each_sublocale'
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:157:in `each_localized_path'
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:145:in `search_file'
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:124:in `find'
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:108:in `load'
from /usr/local/lib/ruby/2.0.0/irb/locale.rb:32:in `initialize'
from /usr/local/lib/ruby/2.0.0/irb/init.rb:114:in `new'
from /usr/local/lib/ruby/2.0.0/irb/init.rb:114:in `init_config'
from /usr/local/lib/ruby/2.0.0/irb/init.rb:16:in `setup'
from /usr/local/lib/ruby/2.0.0/irb.rb:380:in `start'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Have you already installed bundler? If not, try:
gem install bundler
If so, try:
gem install bundler --pre
If you running Ruby version manager, what version are you running? You might be set to the wrong version of Ruby.
I think it would be easier for you if you used RVM or some other version manager.
if you have multiple versions of rubygems installed, uninstall all but the one you want to use.
I think rails 4 requires rubygems 2.x.
Also check the bundler version.

Rake aborted, cannot load file ./bundler/setup, ruby require errors in RubyOnRails application

I've been working on a Ruby on Rails project for class and have run into some problems. When I run bundle install, all of my gems install appropriately. When I run rake db:setup, I get the following error.
tuggernuts2#tn-Extensa5620:~/Workspace/Class/baseball-manager$ rake db:setup
rake aborted!
cannot load such file -- ./bundler/setup
/home/tuggernuts2/Workspace/Class/baseball-manager/config/boot.rb:6:in `<top (required)>'
/home/tuggernuts2/Workspace/Class/baseball-manager/config/application.rb:1:in `<top (required)>'
/home/tuggernuts2/Workspace/Class/baseball-manager/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
I am also get this error when I try to run any of my unit tests:
tuggernuts2#tn-Extensa5620:~/Workspace/Class/baseball-manager$ ruby test/unit/user_test.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require': cannot load such file -- ./bundler/setup (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /home/tuggernuts2/Workspace/Class/baseball-manager/config/boot.rb:6:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/tuggernuts2/Workspace/Class/baseball-manager/config/application.rb:1:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/tuggernuts2/Workspace/Class/baseball-manager/config/environment.rb:2:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/tuggernuts2/Workspace/Class/baseball-manager/test/test_helper.rb:2:in `<top (required)>'
from test/unit/user_test.rb:2:in `require_relative'
from test/unit/user_test.rb:2:in `<main>'
I'm working on this project with a group of 4 others, and no one else is getting these errors so I infer that the problem is with my setup and not with the code.
I'm running ruby version "ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]"
I'm running ruby gems version 1.8.23
I'm running rails version 3.2.5
but when I run rails -v I get the same require error, and the same ./bundler/setup error as above. I've been googling these problems for awhile and non of the solutions I've found so far have helped.
I've tried re-installing gems, I've tried running gem update -system, but that just gives me:
ERROR: While executing gem ... (RuntimeError)
gem update --system is disabled on Debian, because it will overwrite the content of the rubygems Debian package, and might break your Debian system in subtle ways. The Debian-supported way to update rubygems is through apt-get, using Debian official repositories.
If you really know what you are doing, you can still update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment variable, but please remember that this is completely unsupported by Debian.
The rake errors are new as of yesterday, the ruby require errors have been there pretty much since the beginning. Life has been a struggle.
I've tried a bunch of combinations of require, require "./...", require_relative, and nothing seems to fix the require errors.
Any and all help is appreciated. Thanks in advance.
Edit: Output from: bundle exec rake db:setup --trace
tuggernuts2#tn-Extensa5620:~/Workspace/Class/baseball-manager$ bundle exec rake db:setup --trace
rake aborted!
cannot load such file -- ./bundler/setup
/home/tuggernuts2/Workspace/Class/baseball-manager/config/boot.rb:7:in `require'
/home/tuggernuts2/Workspace/Class/baseball-manager/config/boot.rb:7:in `<top (required)>'
/home/tuggernuts2/Workspace/Class/baseball-manager/config/application.rb:1:in `require'
/home/tuggernuts2/Workspace/Class/baseball-manager/config/application.rb:1:in `<top (required)>'
/home/tuggernuts2/Workspace/Class/baseball-manager/Rakefile:5:in `require'
/home/tuggernuts2/Workspace/Class/baseball-manager/Rakefile:5:in `<top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/var/lib/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'

Deploy Rails program to Heroku under Fedora 15

[root#chris-notebook helloworld]# heroku create helloworld --stack cedar
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- readline (LoadError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/heroku-2.8.0/lib/heroku/command/run.rb:1:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/heroku-2.8.0/lib/heroku/command.rb:17:in `block in load'
from /usr/local/lib/ruby/gems/1.9.1/gems/heroku-2.8.0/lib/heroku/command.rb:16:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/heroku-2.8.0/lib/heroku/command.rb:16:in `load'
from /usr/local/lib/ruby/gems/1.9.1/gems/heroku-2.8.0/bin/heroku:13:in `<top (required)>'
from /usr/local/bin/heroku:19:in `load'
from /usr/local/bin/heroku:19:in `<main>'
When I try to create that, every time I got same error.
What should I do? I saw similar problems but under Ubuntu. They solve it by going some place ...src/ruby../ext/readline and then execute
ruby extconf.rb
make
make install
but I don't see that folder in file system. Why is it all so difficult?
Update
Solved by installing next packages
readline-devel.i686
readline-static.i686
And then making similar operations in the folder ext/readline that placed in downloaded sources of ruby.

rake db:migrate postgreSQL

I finally got the gem pg to install. Now when I go to migrate the database I get the following:
$ rake db:migrate
(in c:/rubyDev/bsbaslic)
rake aborted!
no such file to load -- 1.9/pg_ext
c:/Ruby192/lib/ruby/gems/1.9.1/gems/pg-0.10.0/lib/pg.rb:10:in `require'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/pg-0.10.0/lib/pg.rb:10:in `<top (required)>'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:in `require'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:in `block (2 levels) in require'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:in `each'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:in `block in require'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:in `each'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:in `require'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler.rb:112:in `require'
c:/rubyDev/bsbaslic/config/application.rb:7:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
c:/rubyDev/bsbaslic/Rakefile:4:in `<top (required)>'
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `load'
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
c:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in `run'
c:/Ruby192/bin/rake:31:in `<main>'
Does anybody have any ideas as to what it is looking for? I have a pg_ext.so file in the same directory as pg.rb.
Windows programs cannot load .so files - they load .dll files instead. You need a build of pg compiled for Windows, or you need to be running Ruby from within a Linuxy environment such as msys or cygwin.
The problem is in your version of pg gem. There is a special version for windows pg 0.9.0.
In order to have it workingon windows:
uninstall the current pg 0.10.0
install pg as follows: gem install pg --version=0.9.0 -- --with-pg-config=/short/path/to/postresql/bin
(To get short path you can simply change directory to PostgrSQL bin and then type command in cmd, it will automaticaly change path to a short verison)
Then edit your project Gemfile in order to use correct pg gem version (0.9.0)
And that's it.
Good Luck

Resources