cannot load such file == rails/cli error when running rails server - ruby-on-rails

Traceback (most recent call last):
5: from C:/Ruby25-x64/bin/rails:23:in `<main>'
4: from C:/Ruby25-x64/bin/rails:23:in `load'
3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2.1/exe/rails:10:in `<top (required)>'
2: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:34:in `require'
1: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:130:in `require': cannot load such file -- rails/cli (LoadError)
I am not so sure what caused this error. Prior to this I ran into an error regarding railties and what I did was to
gem uninstall railties
gem install railties
I tried bundle install and this didn't change anything. However I bundle exec rails s

Related

require 'bundler' error, cannot load such file -- bundler (LoadError)

Unable to run rails console, rails -v etc. Already tried all of the solutions, reinstalled ruby, installed bundler but neither worked for me.
Traceback (most recent call last):
4: from bin/rails:3:in `<main>'
3: from bin/rails:3:in `load'
2: from /var/www/App/releases/XXXXXXXXXXX/bin/spring:8:in `<top (required)>'
1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)
A few days back I also land up into the same issue, I think it was due to spring caching some gems and configurations. I fixed it by running bundle pristine.
This restores installed gems based on the Gemfile.lock to pristine condition from files located in the gem cache.

Problem making bundle install in the console when i change from ruby 2.3.7 to ruby 2.5

i already try a lot o diferent way but cant solve this problem
.it seems that i cant install gems but i cant figure out why
already try with gem install bundler but steel doestn work
taller_integracion git:(develop) bundle install
Traceback (most recent call last):
7: from /Users/seba/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
6: from /Users/seba/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
5: from /Users/seba/.rvm/gems/ruby-2.5.3/bin/bundle:23:in `<main>'
4: from /Users/seba/.rvm/gems/ruby-2.5.3/bin/bundle:23:in `load'
3: from /Users/seba/.rvm/gems/ruby-2.5.3/gems/bundler-0.9.26/bin/bundle:13:in `<top (required)>'
2: from /Users/seba/.rvm/gems/ruby-2.5.3/gems/bundler-0.9.26/lib/bundler/vendor/thor.rb:124:in `start'
1: from /Users/seba/.rvm/gems/ruby-2.5.3/gems/bundler-0.9.26/lib/bundler/vendor/thor/base.rb:377:in `start'
/Users/seba/.rvm/gems/ruby-2.5.3/gems/bundler-0.9.26/lib/bundler/vendor/thor/shell.rb:10:in `shell': uninitialized constant Thor::Base::Config (NameError)
and if i try with:
taller_integracion git:(develop) bundler install
Traceback (most recent call last):
10: from /Users/seba/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:10:in `<main>'
9: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `run'
8: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `each'
7: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:50:in `block in run'
6: from /Users/seba/.rvm/gems/ruby-2.5.3#global/gems/rubygems-bundler-1.4.5/lib/rubygems_executable_plugin.rb:4:in `block in <top (required)>'
5: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
4: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
3: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
2: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:131:in `<top (required)>'
1: from /Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:124:in `check'
/Users/seba/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:84:in `setup': undefined method `rubygems' for Bundler:Module (NoMethodError)
I faced this problem. I was working on a small project hence I just updated ruby version in gemfile to 2.6.3 and it worked for me.
create a new gemset with this ruby version and then run
gem install bundler
to install bundler with the latest ruby.
Now run
bundle install
if bundle install does not work then try
bundle update
this should do the trick.
If you are still facing the same issue then let me know.

Error when creating a Jekyll project

When I run jekyll new . I have get this error:
Traceback (most recent call last):
11: from /usr/local/bin/jekyll:23:in `<main>'
10: from /usr/local/bin/jekyll:23:in `load'
9: from /var/lib/gems/2.5.0/gems/jekyll-3.8.3/exe/jekyll:8:in `<top (required)>'
8: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
7: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
6: from /var/lib/gems/2.5.0/gems/jekyll-3.8.3/lib/jekyll.rb:33:in `<top (required)>'
5: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
4: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
3: from /var/lib/gems/2.5.0/gems/addressable-2.5.2/lib/addressable/uri.rb:21:in `<top (required)>'
2: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
1: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require': cannot load such file -- public_suffix (LoadError)
error just for jekyll new . and jekyll new blog worked successfuly
( i tested jekyll new . --force but problem is unsolved
and my PATH is:
/home/shahrvand/.nvm/versions/node/v8.11.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/shahrvand/.gem/ruby/2.5.0
and my ruby version is:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
gem version : 2.7.7
jekyll 3.8.3
I'm using Ubuntu 18.04. What does this error mean?
Looks like you are missing the public_suffix gem. Try installing via gem install public_suffix or put it into your Gemfile and re-run bundle install.

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.

Error loading rubygems

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

Resources