0

I am having an issue running a command remotely via a non-interactive SSH session to a Ubuntu 14.04. server.

I want to run a bundle command to execute a Jekyll build. If I SSH into an interactive shell on my server using ssh username@address, and run:

cd /jekyll/site/dir ; /root/gems/bin/bundle exec jekyll build --incremental

It works successfully. However, If I try to run this from my local machine:

ssh username@address "cd /jekyll/site/dir ; /root/gems/bin/bundle exec jekyll build --incremental"

it fails. I have seen other issues, such as

which explain that, in a non-interactive session, the environment might not be set up in the same way as an interactive session by default.

I tried adding some sourcing to the remote command to account for this:

ssh username@address "source /root/.profile ; source /root/.bashrc ; cd /jekyll/site/dir ; /root/gems/bin/bundle exec jekyll build --incremental"

Still, the bundle command doesn't work correctly. The actual error that I get is:

/root/gems/bin/bundle:15:in `<main>': undefined method `b' for "exec":String (NoMethodError)
    from /root/gems/bin/ruby_executable_hooks:24:in `eval'
    from /root/gems/bin/ruby_executable_hooks:24:in `<main>'

Thus, the issue seems to have something to do with bundle/RVM, and perhaps there's some environment thing that I am still missing. I tried searching the web to determine why that error occurs, but I have not been able to pinpoint the issue.

If I cd into the Jekyll site directory in an interactive session, it indicates that

"RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,"

and so on. Perhaps this has something to do with the way that RVM/Ruby/whatever overrides the cd command to trigger that process, and maybe it isn't doing the same thing in the non-interactive session?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
bddicken
  • 1,412
  • 1
  • 15
  • 16
  • Just to clarify, Ruby doesn't do anything with the OS to watch for `cd` or other commands; [RVM does look in local directories](https://rvm.io/workflow/rvmrc) to see if there's a `.rvmrc` setting file for the defaults. RVM's documentation is pretty thorough, and their site is the authoritative source for RVM information. _IF_ you are using .rvmrc and it's bundled with your install, it's possible some local/development environment information is leaking to the production machine and causing havoc. – the Tin Man Feb 06 '20 at 19:50
  • Thanks for the reply. [This post](https://stackoverflow.com/questions/5605277/how-does-rvm-detect-when-youve-changed-directories) seems to indicate that RVM does override cd, but it could be wrong. Also, I did not have a .rvmrc file set up on my server. – bddicken Feb 11 '20 at 20:43

0 Answers0