我正在尝试创建一个新的rails应用程序,但是当我输入命令
时rails new test-app
我收到以下“LoadError”消息:
/home/andrew/.rvm/gems/ruby-2.1.5/bin/rails:23:in `load': cannot load such file -- /home/andrew/.rvm/gems/ruby-2.1.5/gems/rails-4.2.0/bin/rails (LoadError)
from /home/andrew/.rvm/gems/ruby-2.1.5/bin/rails:23:in `<main>'
from /home/andrew/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
from /home/andrew/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
这是/home/andrew/.rvm/gems/ruby-2.1.5/bin /中的rails文件:
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to?:force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
gem 'rails', version
load Gem.bin_path('rails', 'rails', version)
这是我在同一目录中的ruby_executable_hooks文件:
#!/usr/bin/env ruby
title = "ruby #{ARGV*" "}"
$0 = ARGV.shift
Process.setproctitle(title) if Process.methods.include?(:setproctitle)
require 'rubygems'
begin
require 'executable-hooks/hooks'
Gem::ExecutableHooks.run($0)
rescue LoadError
warn "unable to load executable-hooks/hooks" if ENV.key?('ExecutableHooks_DEBUG')
end
eval File.read($0), binding, $0
This问题似乎与我的问题非常相似,但我并不真正理解涉及RVM设置文件的解决方案。当我在创建新的应用程序时明确告诉rails使用旧版本:
rails _3.1.0_ new test-app
这确实没有问题,似乎我可以通过在应用程序初始创建后编辑我的Gemfile来制作rails 4.2.0应用程序。但是如果可能的话,我宁愿选择比这更持久的解决方案。