我从 Github 克隆了一个由我公司内部另一个人开发的 Rails 应用程序。
当我cd
进入应用程序的目录时,我在终端中收到此消息:
You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /Users/george/evil-genius/Loopadoop/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
然后,当我尝试运行任何 rails 命令时,例如rails server
我收到此错误:
/Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [rvm-1.11.3.8] (Gem::LoadError)
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/bin/rails:22:in `<main>'
如果我运行rvm rvmrc to .ruby-version
,我不再收到“您正在使用 '.rvmrc'...”警告,但在尝试运行rails
命令时我仍然收到有关 railties 的相同错误消息。
rvm list
显示安装的这些版本的 Ruby:
rvm rubies
* ruby-1.9.3-p385 [ x86_64 ]
=> ruby-1.9.3-p448 [ x86_64 ]
ruby-2.0.0-p195 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
而我的 rvm 版本是 1.22.18。
发生了什么?我根本不懂 rvm 或 .rvmrc 文件,而我机器上其他应用程序中的所有其他 Rails 东西都可以正常工作。我怎样才能让这个 Rails 应用程序工作?
FWIW,这是.rvmrc
我第一次从 GH 克隆 repo 时文件的样子。(为简洁起见已删除评论):
#!/usr/bin/env zsh
environment_id="ruby-1.9.3-p448@loopAdoop"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
do
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
then \. "${__hook}" || true
fi
done
unset __hook
if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
then
if [[ $- == *i* ]] # check for interactive shells
then printf "%b" "Using: \E[32m$GEM_HOME\E[0m
" # show the user the ruby and gemset they are using in green
else printf "%b" "Using: $GEM_HOME
" # don't use colors in non-interactive shells
fi
fi
else
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
在我运行之后rvm rvmrc to .ruby-version
,该.rvmrc
文件被删除,并生成了两个新文件:.ruby-gemset
,其中仅包含我的应用程序的名称,以及.ruby-version
,其中仅包含文本“ ruby-1.9.3-p448
”