/bin/bash -l or su -l runs profile chruby but GEM_HOME and GEM_PATH are empty #236

Closed
tpitale opened this Issue Jan 3, 2014 · 5 comments

Projects

None yet

3 participants

@tpitale
tpitale commented Jan 3, 2014

I've been trying to build a simple upstart config for a ruby script, but whenever it is run the GEM_HOME and GEM_PATH are empty.

Essentially, I've been trying to su -l -c "echo $GEM_HOME" deploy. I have /etc/profile.d/chruby.sh, and it is being run, and so is the sourced /usr/local/share/chruby/chruby.sh.

I'd be happy to provide any other information. Or maybe it's just obvious as to why this won't work.

@tpitale
tpitale commented Jan 3, 2014

Even inside the upstart script block, if I try to source /usr/local/share/chruby/chruby.sh and then chruby 1.9.3-p484 the GEM_HOME/GEM_PATH are empty.

chruby version is 0.3.8

@postmodern
Owner

There's several things going on here. First you want to run "echo \$GEM_HOME". Secondly, su -l -c isn't the same as bash -l -c.

       -, -l, --login
              Starts the shell as login shell with an environment similar to a
              real login:
                 o      clears all environment variables except for TERM
                 o      initializes  the  environment  variables  HOME, SHELL,
                        USER, LOGNAME, PATH
                 o      changes to the target user's home directory
                 o      sets argv[0] of the shell to '-' in order to make  the
                        shell a login shell

Although, I'm perplexed as to why calling chruby from within the upstart script doesn't work.

@tpitale
tpitale commented Jan 4, 2014

I'll try to build a full, simplified example in the morning.

On Jan 3, 2014, at 9:06 PM, Postmodern notifications@github.com wrote:

There's several things going on here. First you want to run "echo $GEM_HOME". Secondly, su -l -c isn't the same as bash -l -c.

   -, -l, --login
          Starts the shell as login shell with an environment similar to a
          real login:

             o      clears all environment variables except for TERM

             o      initializes  the  environment  variables  HOME, SHELL,
                    USER, LOGNAME, PATH

             o      changes to the target user's home directory

             o      sets argv[0] of the shell to '-' in order to make  the
                    shell a login shell

Although, I'm perplexed as to why calling chruby from within the upstart script doesn't work.


Reply to this email directly or view it on GitHub.

@x-yuri
x-yuri commented Jun 5, 2015

Could it possibly be since the script is run as root?

@tpitale
tpitale commented Jun 5, 2015

I think this is a very old issue, I have upstart working with chruby … sorry I lost track of this issue.

@tpitale tpitale closed this Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment