问题描述
我正在使用Ubuntu 14.04,并且是使用Ruby on Rails的初学者
I'm using Ubuntu 14.04 and I'm a beginner using Ruby on Rails
我最近在安装了rbenv,ruby 2.3.0和rails 4.2.4之后教程:
I recently installed rbenv, ruby 2.3.0 and rails 4.2.4 following the tutorial: https://gorails.com/setup/ubuntu/14.04
安装后,我运行ruby -v和rails -v并获得了预期的版本。到目前为止,一切都很好。然后我运行 rails s
并得到:
After installation, I ran ruby -v and rails -v and got the expected versions. So far so good. Then I ran rails s
and I got:
rails server bin/rails:6: warning: already initialized constant APP_PATH error
要修复它,我跑了:
rake rails:update:bin
遵循以下StackOverflow问题:导致了新错误(我也删除了Spring gem):
To fix it I ran:rake rails:update:bin
following this StackOverflow question: rails server bin/rails:6: warning: already initialized constant APP_PATH error which resulted to a new error (I also removed Spring gem):
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.5.0. Prepending `bundle exec` to your command may solve this.
/my-home-directory/my-ruby-on-rails-project/config/boot.rb:3:in `<top (required)>'
/my-home-directory/my-ruby-on-rails-project/config/application.rb:1:in `<top (required)>'
/my-home-directory/my-ruby-on-rails-project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/my-home-directory/my-ruby-on-rails-project/config/boot.rb:3:in `<top (required)>'
/my-home-directory/my-ruby-on-rails-project/config/application.rb:1:in `<top (required)>'
/my-home-directory/my-ruby-on-rails-project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
我在'bundle exec'之前添加了以下错误:
I prepend 'bundle exec' and got the following error:
/my-home-directory/my-ruby-on-rails-project/.bundle/gems/nokogiri-1.6.7.2/lib/nokogiri.rb:29:in `require': libruby.so.2.2: cannot open shared object file: No such file or directory - /my-home-directory/my-ruby-on-rails-project/.bundle/gems/nokogiri-1.6.7.2/lib/nokogiri/nokogiri.so (LoadError)
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/nokogiri-1.6.7.2/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/nokogiri-1.6.7.2/lib/nokogiri.rb:25:in `<top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/fog-1.23.0/lib/fog/xml.rb:1:in `require'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/fog-1.23.0/lib/fog/xml.rb:1:in `<top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/fog-1.23.0/lib/fog.rb:11:in `require'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/fog-1.23.0/lib/fog.rb:11:in `<top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/carrierwave-0.10.0/lib/carrierwave/storage/fog.rb:3:in `require'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/carrierwave-0.10.0/lib/carrierwave/storage/fog.rb:3:in `<top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/carrierwave-0.10.0/lib/carrierwave/storage.rb:9:in `require'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/carrierwave-0.10.0/lib/carrierwave/storage.rb:9:in `<top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/carrierwave-0.10.0/lib/carrierwave.rb:78:in `require'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/carrierwave-0.10.0/lib/carrierwave.rb:78:in `<top (required)>'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `require'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `block (2 levels) in require'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /my-home-directory/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /my-home-directory/my-ruby-on-rails-project/config/application.rb:7:in `<top (required)>'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:78:in `require'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /my-home-directory/my-ruby-on-rails-project/.bundle/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
在安装rbenv之前,我正在使用RVM,并且弹出相同的错误周围。当我遇到这些问题时,我无法弄清楚自己做了什么更改。
Before installing rbenv, I was using RVM and I had the same errors popping around. I can't figure out what changes I've done when I started having these issues.
出于我的理智,我们非常感谢您的帮助!
For the sake of my sanity, any help is very appreciated!
谢谢大家!
推荐答案
我的一个朋友刚刚帮了忙我,并解决了这个问题。
他的建议:
A friend of mine just helped me and fixed this. What he suggested:
- 在我的项目目录中用以下一行创建文件.ruby-version:ruby-2.3.0 -这样可以确保我们不会加载另一个nokogiri版本
- 运行以下命令删除捆绑程序:rm -rfv .bundle
- 然后运行: bundle
- 运行:bundle exec rails s
- Create a file .ruby-version in my project directory with one line: ruby-2.3.0 - This will make sure that we're not loading another nokogiri version
- Remove the bundler by running: rm -rfv .bundle
- Then run: bundle
- Run: bundle exec rails s
工作就像一种魅力。
我问他为什么他认为我有这些问题,并说:很难说,一个混乱的.bundle目录可以做很多时髦的事情。
Works like a charm.I asked him why he thinks I had these issues and said: Hard to say, a messed up .bundle directory can do a lot of funky stuff.
这篇关于rails服务器bin / rails:6:警告:已经初始化的常量APP_PATH错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!