在运行puma-dev
时尝试访问我的 Rails 应用程序时出现以下错误:
unexpected exit:
from /not/the/correct/ruby/path/ruby_executable_hooks:24:in `<main>'
你如何告诉puma-dev
使用正确的路径来加载带有 RVM 的 gem?
在运行puma-dev
时尝试访问我的 Rails 应用程序时出现以下错误:
unexpected exit:
from /not/the/correct/ruby/path/ruby_executable_hooks:24:in `<main>'
你如何告诉puma-dev
使用正确的路径来加载带有 RVM 的 gem?
我想出了这一点,并想与其他可能正在寻找的人分享。puma-dev
使用该.powenv
文件加载正确的 RVM 配置。您需要将此文件放在 Rails 应用程序的根目录中:
# .powenv
# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi
# load environment of current project ruby
if
[ -n "${rvm_path:-}" ] &&
[ -x "${rvm_path:-}/bin/rvm" ] &&
rvm_project_environment=`"${rvm_path:-}/bin/rvm" . do rvm env --path 2>/dev/null` &&
[ -n "${rvm_project_environment:-}" ] &&
[ -s "${rvm_project_environment:-}" ]
then
echo "RVM loading: ${rvm_project_environment:-}"
\. "${rvm_project_environment:-}"
else
echo "RVM project not found at: $PWD"
fi