我想我弄乱了我的一个项目,现在几乎没有任何命令。
最初我通过RVM安装了所有内容。 Gemfile显示rails 4.1.3
过了一段时间后,我想我可能会尝试更新rails并启动了一些其他项目,其中rails版本是4.2.0并且都运行良好。
最近我回到了第一个部署它的项目。当我注意到我无法在我的工作机器上运行任何开发命令时,我正在配置Capistrano。首先我尝试运行服务器,但出现了这个错误:
$ 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.
所以我想也许我用Capistrano搞砸了一些东西所以我回到了分店大师那里但错误仍然存在。
任何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)
根据建议预先bundle exec
显示另一个错误。例如:
$ 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)
有类似的情况,错误bin/rails:6: warning: already initialized constant APP_PATH
与spring gem有关。运行rake rails:update:bin似乎有所帮助但我无法运行它,因为rake根本不起作用。
所以我尝试重新安装RVM。但没有改变。我甚至删除了RVM并安装了Rbenv。但一切都完全一样。
项目内的版本:
$ 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
执行了一些更新,但在执行rake之后显示与前置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)
没有什么有用的谷歌搜索LoadError: cannot load such file -- gserver
请帮助我:&#39;(
答案 0 :(得分:3)
羞辱我。我没有为项目定义ruby本地版本。
使用RVM时:
$ rvm install 2.1.1
$ rvm use 2.1.1
对于Rbenv:
$ rbenv install 2.1.1
$ rbenv local 2.1.1