mina-deploy / mina

Blazing fast deployer and server automation tool
https://rubygems.org/gems/mina
Other
4.35k stars 490 forks source link

Mina 1.0.2+ error "bash: bundle: command not found" when using `mina console` #476

Closed HappyEmu closed 7 years ago

HappyEmu commented 7 years ago

Hi

I am using Mina version 1.0.3 in a Rails project. When I try to connect to the production console using mina console I get the following error: bash: bundle: command not found. I'm using rbenv on the server where the app is deployed, the :environment task looks as follows:

task :environment do
  invoke :'rbenv:load'
end

While mina ssh, mina log and mina deploy work flawlessly, mina console, mina rake and the likes all produce the above mentioned error.

Am I doing something wrong or is this a bug?

d4be4st commented 7 years ago

I managed to reproduce it.

Have a logical error in my code. Will try to fix it.

molfar commented 7 years ago

@d4be4st so how to deal with this error? I looks like in all these tasks the environment task is not invoked.

Xenofex commented 7 years ago

Encountered the same error here. mina console used to depend on the environment task back in 0.3.8, but not anymore in 1.0.3. It definitely should depend on the 'environment' task.

Xenofex commented 7 years ago

Created #492 to address this

molfar commented 7 years ago

Is it ok that environment would be invoked twice, in Mina::DSL.run and in run_commands task?

d4be4st commented 7 years ago

You are correct @molfar

Need to add some specs to this but #aaf50c5 should fix this

bobmaerten commented 7 years ago

That does not seems to fix (for me at least). I use rbenv and my gems shims are not anywhere in my $PATH, so I have to force it in :environment task

task :environment do
  invoke 'rbenv:load'
  command %[ export PATH="$PATH:$HOME/.rbenv/shims" ]
end

if I override default console task by prepending environment load, my rails console task works:

task console: :environment do
  set :execution_mode, :exec
  in_path fetch(:current_path).to_s do
    command %{#{fetch(:rails)} console}
  end
end

But when I quit the console, another one is launched... o_O

molfar commented 7 years ago

Mina 1.0.6 with rbenv still not working... bash: bundle: command not found It looks like bug is not really fixed yet

Xenofex commented 7 years ago

This is still there.

task :run_commands do
  if commands.run_default?
    invoke :environment
    commands.run(:remote)
  end
end

It appears that commands.run(:remote) happens before invoke :environment. I'm still figuring out why.

UPDATE: now I get what this means and why this is wrong:

The invoke here: put this task in the queue The :run_commands task: comes after everything else.

Therefore this is merely appending the :environment tasks after everything else, which is, too late.

Xenofex commented 7 years ago

Happy New Year!

And... any updates on this?

xikaos commented 7 years ago

@Xenofex I hope so. https://github.com/mina-deploy/mina/commit/aaf50c597223f089103cb9b0d872bd4435edefed

stereodenis commented 7 years ago

@xikaos 1.0.6 not work's for me

havran commented 7 years ago

Hi. I have same problem on my vagrant Ubuntu machine ().

vagrant@vagrant-ubuntu-uidis:/data/form-builder-rails-mina$ mina -V
Mina, version v1.0.6
vagrant@vagrant-ubuntu-uidis:/data/form-builder-rails-mina$ mina console
vagrant@localhost's password:
bundler: command not found: rails
Install missing gem executables with `bundle install`
-----> Loading rbenv
Connection to localhost closed.
ajahongir commented 7 years ago

having same issue

HappyEmu commented 7 years ago

@d4be4st Could we reopen this issue? Seems like the bug still persists.

bindiry commented 7 years ago

I having same issue. mina 1.0.6 with rbenv

bobmaerten commented 7 years ago

I gave up on mina console-ing, I just ssh to my server and bundle exec rails console now. :-/

Martin288 commented 7 years ago

Having same issue.

mina 1.0.6 with rvm.

Currently I just add the below codes in config/deploy.rb and it seems it successfully inject the dependence :enviroment and avoid launching the console twice mentioned by @bobmaerten.

# Fix https://github.com/mina-deploy/mina/issues/476
task :console => :environment do
end
shvetsov commented 7 years ago

@Martin288 or just task console: :environment

molfar commented 7 years ago

I think everything should work out of the box, without any manipulations

Martin288 commented 7 years ago

@shvetsov right, you can omit the empty block. @molfar so do I.

ghost commented 7 years ago

Create #551 to fix this.