Reputation:
I had a fully working Rails server last night. However, on accessing my computer this morning, I found it had crashed. I booted back up, then SSHed on to my remote server, and attempted to restart the server process, first querying:
rails server -h
Which resulted in:
/usr/local/lib/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem railties (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/lib/site_ruby/2.3.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/rails:22:in `<main>'
I then attempted a bundle install
, which threw the following error:
enter code here/usr/local/lib/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/lib/site_ruby/2.3.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/bundle:22:in `<main>'
I then reinstalled Rails with rvm use [email protected] --create
followed by gem install rails
. rails -v
now reports:
Rails 5.0.1
However, when I attempt to start a server process ( rails server -p 80 - b 139.162.246.138
) I get:
Exiting
/home/peter/.rvm/gems/[email protected]/gems/rack-2.0.1/lib/rack/handler.rb:74:in `require': cannot load such file -- rack/handler/- (LoadError)
from /home/peter/.rvm/gems/[email protected]/gems/rack-2.0.1/lib/rack/handler.rb:74:in `try_require'
from /home/peter/.rvm/gems/[email protected]/gems/rack-2.0.1/lib/rack/handler.rb:16:in `get'
from /home/peter/.rvm/gems/[email protected]/gems/rack-2.0.1/lib/rack/server.rb:300:in `server'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands/server.rb:112:in `print_boot_information'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands/server.rb:73:in `start'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/peter/.rvm/gems/[email protected]/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I have tried uninstalling and reinstalling both ruby and rails, and running a new bundle install
. Not getting basically the same error:
/home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
Exiting
/home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/handler.rb:74:in `require': cannot load such file -- rack/handler/- (LoadError)
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/handler.rb:74:in `try_require'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/handler.rb:16:in `get'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/server.rb:300:in `server'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/server.rb:112:in `print_boot_information'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/server.rb:73:in `start'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I have also tried completely uninstalling rails and railties with:
gem uninstall rails -v 5.0.1
gem uninstall railties -v 5.0.1
gem install rails -v 5.0.1
gen install railties -v 5.0.1
Same error.
Attempted to locate problem call with:
sudo grep -rnw './' -e "/var/lib/gems/2.3.0/"
From source directory outputs nothing to console.
Attempting to access the directory listed in the error message results in:
cd /var/lib/gems/
-bash: /home/peter/.rvm/scripts/initialize: No such file or directory
-bash: /home/peter/.rvm/scripts/hook: No such file or directory
Running sudo gem uninstall --all
to remove all gems results in:
You have requested to uninstall the gem:
actioncable-5.0.1
rails-5.0.1 depends on actioncable (= 5.0.1)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] ERROR: While executing gem ... (Gem::DependencyRemovalException)
Uninstallation aborted due to dependent gem(s)
Although removing the rails-5.0.1 gem before running the command fixed this... However, after running this command which is supposed to remove all gems, rails -v
now outputs:
Rails 4.2.7.1
And running gem uninstall rails-4.2.7.1
does not remove this version.
gem uninstall -v rails-4.2.7.1
results in:
ERROR: While executing gem ... (Gem::Requirement::BadRequirementError)
Illformed requirement ["rails-4.2.7.1"]
Update: finally managed to remove rails and ruby. Reinstalled them. Same problem.
Tried creating a rew rails project and the new project does exactly the same thing.
Upvotes: 1
Views: 2124
Reputation: 2748
The moral of this story is that if you mangle something on the command line while invoking rails server, you'll get:
bootsnap-1.3.2/lib/bootsnap/load_path_cache/
core_ext/kernel_require.rb:32:in `require': cannot
load such file -- rack/handler/--some-wrong-option (LoadError)
This is a little ambiguous. It's not that bootsnap
can't load rack, it's that it can't load the rack "some wrong option" handler, because your option is wrong, probably a typo.
Upvotes: 0
Reputation:
After all that work, the solution was simple. I was typing:
rails server -p 80 - b 139.162.246.138
Instead of:
rails server -p 80 -b 139.162.246.138
Upvotes: 3
Reputation: 374
have you rehashed after installing gems using => rbenv ? if not check in the => gemfile to make sure you have the matching ruby versions as well as your => gemfile.lock (in the directory your working in)
Upvotes: 0