" \
\
"
Make sure the gem bundle is installed
" \
"
Run the following from the application directory:
" \
"
bundle install
" \
\
"
Check the application process's execution environment
" \
"
Is the application running under the expected execution environment?" \
" A common problem is that the application runs under a different user than" \
" it is supposed to. The application is currently running as the #{h whoami}
" \
" user — is this expected? Also, check the 'Detailed diagnostics'" \
" » 'Subprocess' tab and double check all information there — is" \
" everything as expected? If not, please fix that.
"
if passenger_user
solution_description <<
"
If the application is not supposed to run as #{h whoami}
," \
" then you can configure this via the" \
" #{h passenger_user}" \
" setting.
"
end
solution_description <<
"
Check that the application has permissions to access the directory from which Bundler loads gems
" \
"
Please check whether the application, which is running as the" \
" #{h whoami}
user, has permissions to access"
if bundle_path
solution_description <<
" #{h bundle_path}
."
else
solution_description <<
" the directory that Bundler tries to load gems from. Unfortunately" \
" #{SHORT_PROGRAM_NAME} was unable to figure out which directory this"
" is because Bundler is too old, so you need to figure out the" \
" directory yourself (or you can upgrade Bundler so that #{SHORT_PROGRAM_NAME}" \
" can figure out the path for you)."
end
solution_description <<
"
" \
\
"
Check whether the application is being run under the correct Ruby interpreter
" \
"
Is the application supposed to be run with #{h ruby}
?" \
" If not, please change the #{h passenger_ruby}" \
" setting.
"
if PlatformInfo.in_rvm?
solution_description <<
"
Check whether the application is being run under the correct RVM gemset
" \
"
Is the application supposed to run under the #{h PlatformInfo.rvm_ruby_string}
" \
" gemset? If not, please change the #{h passenger_ruby}" \
" setting. The documentation for that setting will teach you how to refer" \
" to the proper gemset.
"
end
if ruby =~ %r(^/usr/local/rvm/)
solution_description <<
"
Is your gem bundle installed to the home directory, while at the same" \
" time you are using a Ruby that is installed by RVM in a system-wide manner?
" \
"
Your Ruby interpreter is installed by RVM in a system-wide manner: it is" \
" located in #{h ruby}. If Bundler tries to load gems from " \
"#{h home_dir}
/.rvm/gems, then that won't work.
" \
"
To make Bundler and RVM able to load gems from the home directory, set " \
"#{h passenger_ruby} to an RVM wrapper script " \
"inside the home directory:
\n\n" \
"
\n" \
" - Login as #{h whoami}.
\n"
if PlatformInfo.rvm_installation_mode == :multi
solution_description <<
" - Enable RVM mixed mode by running:\n" \
"
rvm user gemsets
\n"
end
solution_description <<
" - Run this to find out what to set" \
" #{h passenger_ruby} to:\n" \
"
#{h PlatformInfo.ruby_command} \\\n" \
"#{PhusionPassenger.bin_dir}/passenger-config about ruby-command
\n" \
"
\n\n"
end
if PlatformInfo.in_rvm?
solution_description <<
"
Reset your RVM gemset
" \
"
Sometimes, RVM gemsets maybe be broken. " \
"" \
"Try resetting them.
"
end
attach_solution_description_html_to_exception(e, solution_description)
end
raise e
end
def check_execution_environment_solution_description(passenger_user, passenger_user_doc, bundle_path)
result = ''
result << %Q{
Check the application process's execution environment
Is the application running under the expected execution environment?
A common problem is that the application runs under a different user than
it is supposed to. The application is currently running as the #{h whoami}
user — is this expected? Also, check the 'Detailed diagnostics'
» 'Subprocess' tab and double check all information there — is
everything as expected?
}
if passenger_user
result << %Q{
If the application is not supposed to run as #{h whoami}
,
then you can configure this via the
#{h passenger_user}
setting.
}
end
result << %Q{
Check that the application has permissions to access the directory from which Bundler loads gems
Please check whether the application, which is running as the
#{h whoami}
user, has permissions to access
}
if bundle_path
result << %Q{
#{h bundle_path}
.
}
else
result << %Q{
the directory that Bundler tries to load gems from. Unfortunately
#{SHORT_PROGRAM_NAME} was unable to figure out which directory this
is because Bundler is too old, so you need to figure out the
directory yourself (or you can upgrade Bundler so that #{SHORT_PROGRAM_NAME}
can figure out the path for you).
}
end
result << %Q{
}
result
end
def attach_problem_description_html_to_exception(e, html)
metaclass = class << e; self; end
metaclass.send(:define_method, :problem_description_html) do
html
end
end
def attach_solution_description_html_to_exception(e, html)
metaclass = class << e; self; end
metaclass.send(:define_method, :solution_description_html) do
html
end
end
def try_write_file(path, contents)
@main_app.try_write_file(path, contents)
end
def h(text)
require 'erb' if !defined?(ERB)
ERB::Util.h(text)
end
def whoami
require 'etc' if !defined?(Etc)
begin
user = Etc.getpwuid(Process.uid)
rescue ArgumentError
user = nil
end
if user
user.name
else
"##{Process.uid}"
end
end
def home_dir
PhusionPassenger.home_dir
end
end
end # module PhusionPassenger