简体   繁体   English

LoadError:无法加载此类文件--gserver

[英]LoadError: cannot load such file — gserver

I think I messed up one of my projects and now it won't run almost any command. 我想我弄乱了我的一个项目,现在它几乎不会运行任何命令。

Initially I installed all through RVM. 最初我通过RVM安装了所有内容。 The Gemfile shows rails 4.1.3 Gemfile显示了rails 4.1.3

After some time I think I may tried to update rails and started a couple of other projects which rails version is 4.2.0 and both run fine. 一段时间后,我想我可能会尝试更新rails并启动了几个其他项目,其中rails版本是4.2.0并且都运行良好。

Recently I went back on the first project to deploy it. 最近我回到了第一个部署它的项目。 I was configuring Capistrano when I noticed that I couldn't run any development commands on my working machine. 当我注意到我无法在我的工作机器上运行任何开发命令时,我正在配置Capistrano。 First I tried to run the server but this error appeared: 首先,我尝试运行服务器,但出现此错误:

$ rails server

bin/rails:6: warning: already initialized constant APP_PATH
/home/axl/coding/bfq/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate    Generate new code (short-cut alias: "g")
 console     Start the Rails console (short-cut alias: "c")
 server      Start the Rails server (short-cut alias: "s")
 dbconsole   Start a console for the database specified in config/database.yml
             (short-cut alias: "db")
 new         Create a new Rails application. "rails new my_app" creates a
             new application called MyApp in "./my_app"

In addition to those, there are:
 application  Generate the Rails application code
 destroy      Undo code generated with "generate" (short-cut alias: "d")
 plugin new   Generates skeleton for developing a Rails plugin
 runner       Run a piece of code in the application environment (short-cut alias: "r")

All commands can be run with -h (or --help) for more information.

So I thought maybe I screw something with Capistrano so I returned to branch master but the error was still there. 所以我想也许我和卡皮斯特拉诺搞了一些东西,所以我回到了分公司大师,但错误依旧存在。

Any rake call returns this: 任何rake调用都会返回:

$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/home/axl/coding/bfq/config/boot.rb:4:in `<top (required)>'
/home/axl/coding/bfq/config/application.rb:1:in `<top (required)>'
/home/axl/coding/bfq  fiscal-quadrum/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/axl/coding/bfq/config/boot.rb:4:in `<top (required)>'
/home/axl/coding/bfq/config/application.rb:1:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

Prepending bundle exec as suggested shows another error. 按建议添加bundle exec显示另一个错误。 For example: 例如:

$ bundle exec rake db:setup
rake aborted!
LoadError: cannot load such file -- gserver
/home/axl/coding/bfq/config/application.rb:7:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `require'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

There are similar cases, error bin/rails:6: warning: already initialized constant APP_PATH is related to spring gem. 有类似的情况,错误bin/rails:6: warning: already initialized constant APP_PATH与spring gem有关。 Running rake rails:update:bin seems to help but I can't run it since rake doesn't work at all. 运行rake rails:update:bin似乎有帮助但我无法运行它,因为rake根本不起作用。

So I tried reinstalling RVM. 所以我尝试重新安装RVM。 But nothing changed. 但没有改变。 I even removed RVM and installed Rbenv. 我甚至删除了RVM并安装了Rbenv。 But everything is exactly the same. 但一切都完全一样。

Versions inside the project: 项目内的版本:

$ ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

$ gem --version
2.4.5

$ rake --version
rake, version 10.4.2

$ rails --version
Rails 4.1.6

bundle update does some updates but after that executing rake shows the same error as prepending bundle exec : bundle update做一些更新,但是在执行rake之后显示与preing bundle exec相同的错误:

$ rake
rake aborted!
LoadError: cannot load such file -- gserver
/home/axl/coding/bfq/config/application.rb:7:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

And there is nothing useful googling LoadError: cannot load such file -- gserver 并没有什么有用的谷歌搜索LoadError: cannot load such file -- gserver

Please, help me :'( 请帮我 :'(

Shame on me. 对我感到羞耻。 I didn't define ruby local version for the project. 我没有为项目定义ruby本地版本。

When using RVM: 使用RVM时:

$ rvm install 2.1.1
$ rvm use 2.1.1

For Rbenv: 对于Rbenv:

$ rbenv install 2.1.1
$ rbenv local 2.1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM