Inconsistent Behavior Between ssh execution and "knife ssh" execution

I’m writing a cookbook for a Torquebox-based application server, and seeing some odd behavior when using knife for deploys.

When logging into a box as user “ubuntu” and running “sudo chef-client”, everything works fine.

When I do the same via “knife ssh”, I get GemNotFound errors when calling rake. This leads me to believe it’s an environment/path problem, but I can’t figure out what would be different. Does knife alter the environment in which a command is executed?

Here is my knife command: knife ssh “role:rails_app_server” interactive -x ubuntu -a ec2.public_hostname -C 1

And here is the error with debug level output:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17 +0000] INFO: execute[jruby -J-Xmx2048m -J-Xms512m -J-Xmn128m -S bundle install --without development test --deployment] ran successfully
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17 +0000] INFO: deploy[/var/www/shareaholic_on_rails] made pre-migration symlinks
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] set user to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] set group to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] migrating torquebox with environment RACK_ENV=‘production’ JRUBY_OPTS=’–1.9’
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] DEBUG: Executing jruby -S bundle exec rake db:migrate
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: ---- Begin output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: STDOUT:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: STDERR: Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
ec2-23-20-158-139.compute-1.amazonaws.com materialize at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:90
ec2-23-20-158-139.compute-1.amazonaws.com map! at org/jruby/RubyArray.java:2371
ec2-23-20-158-139.compute-1.amazonaws.com materialize at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83
ec2-23-20-158-139.compute-1.amazonaws.com specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:127
ec2-23-20-158-139.compute-1.amazonaws.com specs_for at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:172
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:161
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/environment.rb:23
ec2-23-20-158-139.compute-1.amazonaws.com setup at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/runtime.rb:11
ec2-23-20-158-139.compute-1.amazonaws.com setup at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler.rb:107
ec2-23-20-158-139.compute-1.amazonaws.com (root) at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/setup.rb:17
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: ---- End output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: Ran jruby -S bundle exec rake db:migrate returned 1

Any thoughts would be much appreciated.

–Robby


Robby Grossman
@freerobby (http://twitter.com/freerobby)
http://rob.by (http://rob.by/)

There is definitely a difference between running in a tty as opposed to a
ptty (run into this all the time when executing remote commands with ssh)
and that's probably what's happening with knife ssh as well. You can
verify by running 'env' from the command line and again when using knife
ssh as the same user and compare the output. You'll probably find the
answer to your question there.

MG

On Mon, Jul 23, 2012 at 2:16 PM, Robby Grossman robby@freerobby.com wrote:

I'm writing a cookbook for a Torquebox-based application server, and
seeing some odd behavior when using knife for deploys.

When logging into a box as user "ubuntu" and running "sudo chef-client",
everything works fine.

When I do the same via "knife ssh", I get GemNotFound errors when calling
rake. This leads me to believe it's an environment/path problem, but I
can't figure out what would be different. Does knife alter the environment
in which a command is executed?

Here is my knife command: knife ssh "role:rails_app_server" interactive -x
ubuntu -a ec2.public_hostname -C 1

And here is the error with debug level output:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17
+0000] INFO: execute[jruby -J-Xmx2048m -J-Xms512m -J-Xmn128m -S bundle
install --without development test --deployment] ran successfully
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17
+0000] INFO: deploy[/var/www/shareaholic_on_rails] made pre-migration
symlinks
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] INFO: deploy[/var/www/shareaholic_on_rails] set user to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] INFO: deploy[/var/www/shareaholic_on_rails] set group to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] INFO: deploy[/var/www/shareaholic_on_rails] migrating torquebox with
environment RACK_ENV='production' JRUBY_OPTS='--1.9'
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] DEBUG: Executing jruby -S bundle exec rake db:migrate
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: ---- Begin output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: STDOUT:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: STDERR: Bundler::GemNotFound: Could not find rake-0.9.2.2 in
any of the sources
ec2-23-20-158-139.compute-1.amazonaws.com materialize at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:90
ec2-23-20-158-139.compute-1.amazonaws.com map! at
org/jruby/RubyArray.java:2371
ec2-23-20-158-139.compute-1.amazonaws.com materialize at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83
ec2-23-20-158-139.compute-1.amazonaws.com specs at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:127
ec2-23-20-158-139.compute-1.amazonaws.com specs_for at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:172
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:161
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/environment.rb:23
ec2-23-20-158-139.compute-1.amazonaws.com setup at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/runtime.rb:11
ec2-23-20-158-139.compute-1.amazonaws.com setup at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler.rb:107
ec2-23-20-158-139.compute-1.amazonaws.com (root) at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/setup.rb:17
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: ---- End output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: Ran jruby -S bundle exec rake db:migrate returned 1

Any thoughts would be much appreciated.

--Robby

--
Robby Grossman
@freerobby http://twitter.com/freerobby
http://rob.by

Actually I said that wrong. ptty is something you can force with ssh to
resolve some issues with not being on a tty, such as trying to remotely
edit a file.

But the problem I described is probably what you want to look at even
though I used the wrong term. Your environment vars will be different
between a remote session and a tty session so check them out.

MG

On Mon, Jul 23, 2012 at 3:12 PM, Michael Glenney mike.glenney@gmail.comwrote:

There is definitely a difference between running in a tty as opposed to a
ptty (run into this all the time when executing remote commands with ssh)
and that's probably what's happening with knife ssh as well. You can
verify by running 'env' from the command line and again when using knife
ssh as the same user and compare the output. You'll probably find the
answer to your question there.

MG

On Mon, Jul 23, 2012 at 2:16 PM, Robby Grossman robby@freerobby.comwrote:

I'm writing a cookbook for a Torquebox-based application server, and
seeing some odd behavior when using knife for deploys.

When logging into a box as user "ubuntu" and running "sudo chef-client",
everything works fine.

When I do the same via "knife ssh", I get GemNotFound errors when calling
rake. This leads me to believe it's an environment/path problem, but I
can't figure out what would be different. Does knife alter the environment
in which a command is executed?

Here is my knife command: knife ssh "role:rails_app_server" interactive
-x ubuntu -a ec2.public_hostname -C 1

And here is the error with debug level output:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17
+0000] INFO: execute[jruby -J-Xmx2048m -J-Xms512m -J-Xmn128m -S bundle
install --without development test --deployment] ran successfully
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17
+0000] INFO: deploy[/var/www/shareaholic_on_rails] made pre-migration
symlinks
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] INFO: deploy[/var/www/shareaholic_on_rails] set user to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] INFO: deploy[/var/www/shareaholic_on_rails] set group to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] INFO: deploy[/var/www/shareaholic_on_rails] migrating torquebox with
environment RACK_ENV='production' JRUBY_OPTS='--1.9'
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23
+0000] DEBUG: Executing jruby -S bundle exec rake db:migrate
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: ---- Begin output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: STDOUT:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: STDERR: Bundler::GemNotFound: Could not find rake-0.9.2.2 in
any of the sources
ec2-23-20-158-139.compute-1.amazonaws.com materialize at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:90
ec2-23-20-158-139.compute-1.amazonaws.com map! at
org/jruby/RubyArray.java:2371
ec2-23-20-158-139.compute-1.amazonaws.com materialize at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83
ec2-23-20-158-139.compute-1.amazonaws.com specs at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:127
ec2-23-20-158-139.compute-1.amazonaws.com specs_for at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:172
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:161
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/environment.rb:23
ec2-23-20-158-139.compute-1.amazonaws.com setup at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/runtime.rb:11
ec2-23-20-158-139.compute-1.amazonaws.com setup at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler.rb:107
ec2-23-20-158-139.compute-1.amazonaws.com (root) at
/usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/setup.rb:17
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: ---- End output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47
+0000] DEBUG: Ran jruby -S bundle exec rake db:migrate returned 1

Any thoughts would be much appreciated.

--Robby

--
Robby Grossman
@freerobby http://twitter.com/freerobby
http://rob.by

Thanks Michael, that combined with some feedback I got in IRC was helpful. I'm still trying to figure out exactly which difference is causing the failure; I'll confirm once I have things working.

--
Robby Grossman
@freerobby (http://twitter.com/freerobby)
http://rob.by (http://rob.by/)

On Monday, July 23, 2012 at 6:17 PM, Michael Glenney wrote:

Actually I said that wrong. ptty is something you can force with ssh to resolve some issues with not being on a tty, such as trying to remotely edit a file.

But the problem I described is probably what you want to look at even though I used the wrong term. Your environment vars will be different between a remote session and a tty session so check them out.

MG

On Mon, Jul 23, 2012 at 3:12 PM, Michael Glenney <mike.glenney@gmail.com (mailto:mike.glenney@gmail.com)> wrote:

There is definitely a difference between running in a tty as opposed to a ptty (run into this all the time when executing remote commands with ssh) and that's probably what's happening with knife ssh as well. You can verify by running 'env' from the command line and again when using knife ssh as the same user and compare the output. You'll probably find the answer to your question there.

MG

On Mon, Jul 23, 2012 at 2:16 PM, Robby Grossman <robby@freerobby.com (mailto:robby@freerobby.com)> wrote:

I'm writing a cookbook for a Torquebox-based application server, and seeing some odd behavior when using knife for deploys.

When logging into a box as user "ubuntu" and running "sudo chef-client", everything works fine.

When I do the same via "knife ssh", I get GemNotFound errors when calling rake. This leads me to believe it's an environment/path problem, but I can't figure out what would be different. Does knife alter the environment in which a command is executed?

Here is my knife command: knife ssh "role:rails_app_server" interactive -x ubuntu -a ec2.public_hostname -C 1

And here is the error with debug level output:
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:17 +0000] INFO: execute[jruby -J-Xmx2048m -J-Xms512m -J-Xmn128m -S bundle install --without development test --deployment] ran successfully
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:17 +0000] INFO: deploy[/var/www/shareaholic_on_rails] made pre-migration symlinks
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] set user to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] set group to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] migrating torquebox with environment RACK_ENV='production' JRUBY_OPTS='--1.9'
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:23 +0000] DEBUG: Executing jruby -S bundle exec rake db:migrate
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: ---- Begin output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: STDOUT:
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: STDERR: Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) materialize at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:90
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) map! at org/jruby/RubyArray.java:2371
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) materialize at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:127
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) specs_for at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:172
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) requested_specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:161
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) requested_specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/environment.rb:23
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) setup at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/runtime.rb:11
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) setup at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler.rb:107
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) (root) at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/setup.rb:17
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: ---- End output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com (http://ec2-23-20-158-139.compute-1.amazonaws.com) [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: Ran jruby -S bundle exec rake db:migrate returned 1

Any thoughts would be much appreciated.

--Robby

--
Robby Grossman
@freerobby (http://twitter.com/freerobby)
http://rob.by (http://rob.by/)

Do you have rake gem in ur Gemfile? If not add rake gem in ur gemfile and give one more shot.

Via Millisami'z iPhone

On Jul 24, 2012, at 3:01 AM, Robby Grossman robby@freerobby.com wrote:

I'm writing a cookbook for a Torquebox-based application server, and seeing some odd behavior when using knife for deploys.

When logging into a box as user "ubuntu" and running "sudo chef-client", everything works fine.

When I do the same via "knife ssh", I get GemNotFound errors when calling rake. This leads me to believe it's an environment/path problem, but I can't figure out what would be different. Does knife alter the environment in which a command is executed?

Here is my knife command: knife ssh "role:rails_app_server" interactive -x ubuntu -a ec2.public_hostname -C 1

And here is the error with debug level output:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17 +0000] INFO: execute[jruby -J-Xmx2048m -J-Xms512m -J-Xmn128m -S bundle install --without development test --deployment] ran successfully
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:17 +0000] INFO: deploy[/var/www/shareaholic_on_rails] made pre-migration symlinks
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] set user to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] set group to torquebox
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] INFO: deploy[/var/www/shareaholic_on_rails] migrating torquebox with environment RACK_ENV='production' JRUBY_OPTS='--1.9'
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:23 +0000] DEBUG: Executing jruby -S bundle exec rake db:migrate
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: ---- Begin output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: STDOUT:
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: STDERR: Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
ec2-23-20-158-139.compute-1.amazonaws.com materialize at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:90
ec2-23-20-158-139.compute-1.amazonaws.com map! at org/jruby/RubyArray.java:2371
ec2-23-20-158-139.compute-1.amazonaws.com materialize at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83
ec2-23-20-158-139.compute-1.amazonaws.com specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:127
ec2-23-20-158-139.compute-1.amazonaws.com specs_for at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:172
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/definition.rb:161
ec2-23-20-158-139.compute-1.amazonaws.com requested_specs at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/environment.rb:23
ec2-23-20-158-139.compute-1.amazonaws.com setup at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/runtime.rb:11
ec2-23-20-158-139.compute-1.amazonaws.com setup at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler.rb:107
ec2-23-20-158-139.compute-1.amazonaws.com (root) at /usr/local/share/torquebox-2.x.incremental.1103/jruby/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/setup.rb:17
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: ---- End output of jruby -S bundle exec rake db:migrate ----
ec2-23-20-158-139.compute-1.amazonaws.com [Mon, 23 Jul 2012 20:58:47 +0000] DEBUG: Ran jruby -S bundle exec rake db:migrate returned 1

Any thoughts would be much appreciated.

--Robby

--
Robby Grossman
@freerobby
http://rob.by