Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
thaichors3000 opened this issue Jan 24, 2017 · 8 comments
Closed

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

thaichors3000 opened this issue Jan 24, 2017 · 8 comments

Comments

@thaichors3000
Copy link

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.

thaichors3000 added a commit to thaichors3000/mina that referenced this issue Jan 24, 2017
@molfar
Copy link

molfar commented Jan 25, 2017

I wrote the same issue #476

@bindiry
Copy link

bindiry commented Mar 16, 2017

I have the same issue.

@hovancik
Copy link
Contributor

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

@bindiry
Copy link

bindiry commented Apr 28, 2017

@hovancik Thank you, it is worked for me.

@molfar
Copy link

molfar commented Apr 28, 2017

But how can it be fixed? To work just out of the box, without any hacks

@d4be4st
Copy link
Member

d4be4st commented Sep 8, 2017

@d4be4st d4be4st closed this as completed Sep 8, 2017
d4be4st added a commit that referenced this issue Sep 8, 2017
@NicosKaralis
Copy link

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?

@d4be4st
Copy link
Member

d4be4st commented Sep 29, 2017

mina 1.1.0 introduced local_environment and remote_environment 972a26c

You can use that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants