Mina: Mina console 'bash: bundle: command not found'

Created on 24 Jan 2017  ·  8Comments  ·  Source: mina-deploy/mina

mina console raise error bash: bundle: command not found

As I review source code, what mina console does is

  1. cd to current_path
  2. execute rails c

However, when we use rvm or rben, we need to load ruby version with gemset first.

Most helpful comment

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


desc "Starts an interactive rails console."
task :c => :environment do
invoke :'console'
end
```

All 8 comments

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


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 [email protected] -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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bilge picture Bilge  ·  9Comments

misteral picture misteral  ·  10Comments

davidhq picture davidhq  ·  10Comments

amargherio picture amargherio  ·  10Comments

syamilmj picture syamilmj  ·  11Comments