Closed thaichors3000 closed 7 years ago
I wrote the same issue https://github.com/mina-deploy/mina/issues/476
I have the same issue.
This works for me with rbenv:
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
# invoke :'rvm:use[ruby-1.9.3-p125@default]'
end
then
desc "Starts an interactive rails console."
task :c => :environment do
invoke :'console'
end
@hovancik Thank you, it is worked for me.
But how can it be fixed? To work just out of the box, without any hacks
please take a look at https://github.com/mina-deploy/mina/blob/master/docs/faq.md#--command-not-found-bundle
About this, I still have this problem
In my case is because I need to load rbenv first to then run bundle
$ mina console -s --trace
** Invoke console (first_time)
** Execute console
** Invoke debug_configuration_variables (first_time)
** Execute debug_configuration_variables
** Invoke run_commands (first_time)
** Execute run_commands
** Invoke environment (first_time)
** Execute environment
** Invoke rbenv:load (first_time)
** Execute rbenv:load
** Invoke nvm:load (first_time)
** Execute nvm:load
#!/usr/bin/env bash
# Executing the following via 'ssh deployer@165.227.180.208 -i config/deployment_key -p 22 -tt':
#
echo "-----> Loading rbenv"
export RBENV_ROOT="$HOME/.rbenv"
export PATH="$HOME/.rbenv/bin:$PATH"
if ! which rbenv >/dev/null; then
echo "! rbenv not found"
echo "! If rbenv is installed, check your :rbenv_path setting."
exit 1
fi
eval "$(rbenv init -)"
echo "-----> Loading nvm"
[ -s "/home/deployer/.nvm/nvm.sh" ] && . "/home/deployer/.nvm/nvm.sh"
(cd /home/deployer/app/current && RAILS_ENV="production" bundle exec rails console && cd -)
echo "-----> Loading rbenv"
export RBENV_ROOT="$HOME/.rbenv"
export PATH="$HOME/.rbenv/bin:$PATH"
if ! which rbenv >/dev/null; then
echo "! rbenv not found"
echo "! If rbenv is installed, check your :rbenv_path setting."
exit 1
fi
eval "$(rbenv init -)"
echo "-----> Loading nvm"
[ -s "/home/deployer/.nvm/nvm.sh" ] && . "/home/deployer/.nvm/nvm.sh"
Elapsed time: 0.00 seconds
As you can see in the output above the environment
task is called after the console
. Also the rbenv:load
task is called twice.
Currently I'm doing like this:
# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
task :load_env do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
invoke :'rbenv:load'
invoke :'nvm:load'
end
task environment: :load_env
task console: :load_env
Is there a more practical way to fix this?
mina 1.1.0 introduced local_environment
and remote_environment
https://github.com/mina-deploy/mina/commit/972a26ce354e8031a0656c16783c02390c821e33
You can use that
mina console
raise errorbash: bundle: command not found
As I review source code, what mina console does is
rails c
However, when we use rvm or rben, we need to load ruby version with gemset first.