Repairing Rails and Server and on Nitrous.io

好久不见. 提交于 2020-01-05 08:32:32

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19780416/repairing-rails-and-server-and-on-nitrous-io

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!