I cannot execute rails console - ruby-on-rails

I am getting an error I have no clue how to fix it.
$ rails console
/Users/liviu-mac/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/liviu-mac/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/liviu-mac/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liviu-mac/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:77:in `preload'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:143:in `serve'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:131:in `block in run'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:125:in `loop'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:125:in `run'
from /Users/liviu-mac/rails_projects/instrumon/vendor/bundle/gems/spring-1.6.1/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/liviu-mac/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liviu-mac/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
$ rails -v
Rails 4.2.5
$ rvm current
ruby-2.2.3
$ irb
2.3.0 :001 >
I am able to start the server with rails s and the app is working. I am able to deploy on Heroku and I can execute rails dbconsole.

Downgraded bundler from 1.11.x to 1.10.2
Removed the folder .bundler from ~ and any main folder of all rails projects (several)
Executed from the main folder of any rails project the command: bundle install --system
Problem solved.

Related

Rails 5: Error with spring when run devise:install

I am trying make a API with Rails
Ruby version: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
Rails version: Rails 5.2.4.1
I added the devise gem to the gemfile and ran the bundle, without errors. When I tried to run $ rails generate devise: install, this error occurred:
/home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:122:in `ensure in preload': undefined method `application' for Rails:Module (NoMethodError)
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:126:in `preload'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:157:in `serve'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /home/isaac/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from -e:1:in `<main>'
Try restarting the spring server by using the following commands:
bin/spring stop
bin/spring start

rails 4 can't start server after upgrading to rails 4 from rails 3

After upgrading from rails 3 to rails 4 I am unable to start it locally. This is just on my computer since other dev who work with me don't experience this.
I also had to uninstall and install again ruby 2.1.2 since apparently it was installed under root (now it's under my username).
$ bundle exec rails s
/Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/server.rb:3:in `require': cannot load such file -- action_dispatch (LoadError)
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/server.rb:3:in `<top (required)>'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:128:in `require'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:128:in `require_command!'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:74:in `server'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I am also unable to load my console
$ bundle exec rails c
/Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails.rb:5:in `require': cannot load such file -- active_support (LoadError)
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails.rb:5:in `<top (required)>'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/all.rb:1:in `require'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/all.rb:1:in `<top (required)>'
from /Volumes/fiverr_dev/5rr_v2/config/application.rb:1:in `require'
from /Volumes/fiverr_dev/5rr_v2/config/application.rb:1:in `<top (required)>'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:146:in `require'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:146:in `require_application_and_environment!'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/ohad/.rvm/gems/ruby-2.1.2#project_gemset/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
bundle install
Using rake 10.3.2
Using aasm 3.4.0
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.6
.....
Check permissions, may be you don't have necessary to read the file - you say that initially ruby was installed under root, so may be you didn't fix it completely (eg. here's the same problem Rails: no such file to load -- action_dispatch). Try running rails s under root, if it works then the reason is found.
After trying a bunch of solutions,
Reinstalling worked
rvm get stable
rvm gemset delete fiverr_v2
bundle install

Repairing Rails and Server and on Nitrous.io

I was doing One Month Rails's tutorial on Nitrous.io. At one point, some weird files appeared on my tree, and I deleted them. Everything stopped working.
I ran:
$ git add .
$ git checkout -f
and restored the tree.
BUT, when I ran:
$ rails server
I get:
action#first-project-48185:~/pinteresting$ rails server
-bash: rails: command not found
I also tried:
$ ruby -v #and got an older version, so I reinstalled it
$ rails -v
action#first-project-48185:~/pinteresting$ rails -v
-bash: rails: command not found
When I run:
$ ruby -v #on MAC terminal, I get the correct version
$ rails -v #on MAC terminal, I get the correct version
Interestingly, when I run:
$ rails server or $ rails server -p 4000
I get:
Franciscos-MacBook-Pro:pinteresting franciscomello$ rails server
/Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
and a bunch of other text below:
from /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:2:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/franciscomello/Desktop/pinteresting/config/application.rb:7:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Franciscos-MacBook-Pro:pinteresting franciscomello$ rails server -p 4000
/Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:2:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/franciscomello/Desktop/pinteresting/config/application.rb:7:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
What's frustrating is I was on my largest streak without any errors or bugs :(
Any ideas?
I can't tell why Rails is no longer working from those errors, but I would recommend reinstalling rails. Run the following command to reinstall Rails:
gem install rails
From here you should be able to run rails server.
You could also run bundle install within the project directory if your Gemfile includes other gems which need to be installed.

Error Starting Rails Server on New Local Machine Running Existing Rails App

When I run
./script/server
I get the following error message and I can't seem to find how to fix the problem. The folder is on my Desktop and is a checkout from an SVN Repository on a new machine running MacOSX 10.8.3.
/Users/martin/Desktop/[FOLDER NAME]/config/boot.rb:89:in `load_rubygems': undefined method `set_paths' for Gem:Module (NoMethodError)
from /Users/martin/Desktop/[FOLDER NAME]/config/boot.rb:52:in `load_initializer'
from /Users/martin/Desktop/[FOLDER NAME]/config/boot.rb:39:in `run'
from /Users/martin/Desktop/[FOLDER NAME]/config/boot.rb:11:in `boot!'
from /Users/martin/Desktop/[FOLDER NAME]/config/boot.rb:115:in `<top (required)>'
from /Users/martin/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/martin/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ./script/server:2:in `<main>'
Does anyone have any ideas on how to fix/troubleshoot?
If I run which -a ruby I get:
/Users/martin/.rbenv/shims/ruby
/Users/martin/.rbenv/shims/ruby
/Users/martin/.rbenv/shims/ruby
/Users/martin/.rbenv/shims/ruby
/Users/martin/.rbenv/shims/ruby
/usr/bin/ruby
rails -v
Rails 4.0.0
ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0]
Running script/server gives a different error
/Users/martin/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- script/../config/boot (LoadError)
from /Users/martin/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from script/server:2:in `<main>'

Unable to execute "heroku create"

I have just installed heroku and plan to use it with rails on Ruby. However, when I run "heroku create" command I get this:
hadoop#master:~/rails_projects/first_app> gem install heroku
Successfully installed heroku-2.16.3
1 gem installed
Installing ri documentation for heroku-2.16.3...
Installing RDoc documentation for heroku-2.16.3...
hadoop#master:~/rails_projects/first_app> heroku -v
/home/hadoop/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- readline (LoadError)
from /home/hadoop/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/heroku-2.16.3/lib/heroku/command/run.rb:1:in `<top (required)>'
from /home/hadoop/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/hadoop/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/heroku-2.16.3/lib/heroku/command.rb:14:in `block in load'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/heroku-2.16.3/lib/heroku/command.rb:13:in `each'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/heroku-2.16.3/lib/heroku/command.rb:13:in `load'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/heroku-2.16.3/bin/heroku:12:in `<top (required)>'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/bin/heroku:19:in `load'
from /home/hadoop/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/bin/heroku:19:in `<main>'
hadoop#master:~/rails_projects/first_app
Is there something wrong with versions I am using?
The problem here is with RVM and readline - checkout
https://rvm.io/packages/readline/

Resources