unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* $USER and $HOME shell variables not set
@ 2015-03-27 14:32 Russell Jennings
  2015-03-27 18:34 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Russell Jennings @ 2015-03-27 14:32 UTC (permalink / raw)
  To: unicorn-public

Hello,

I am running into some issues with these variables being set - since I am spawning a script from a unicorn worker (via a rails controller) I figured I’d ask here. 

Here is the stackoverflow with the full background:
http://stackoverflow.com/questions/29233181/why-is-envhome-nil-in-my-rake-task

in short: does unicorn have anything to do with $HOME or $USER not being defined? From what I can tell, that its unicorn is the only thing thats different versus running the same ruby via a rails console (which does indeed set those shell variables correctly)

in no mans land, so any hep or insight would be greatly appreciated. 

Thanks,
Russell

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: $USER and $HOME shell variables not set
  2015-03-27 14:32 $USER and $HOME shell variables not set Russell Jennings
@ 2015-03-27 18:34 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-03-27 18:34 UTC (permalink / raw)
  To: Russell Jennings; +Cc: unicorn-public

Russell Jennings <violentpurr@gmail.com> wrote:
> Hello,
> 
> I am running into some issues with these variables being set - since I
> am spawning a script from a unicorn worker (via a rails controller) I
> figured I’d ask here. 
> 
> Here is the stackoverflow with the full background:
> http://stackoverflow.com/questions/29233181/why-is-envhome-nil-in-my-rake-task
> 
> in short: does unicorn have anything to do with $HOME or $USER not
> being defined?

Nope, unicorn itself does not change these variables.  We only set
UNICORN_FD (for SIGUSR2 upgrades), PWD (if working_directory is used).

Your init system may change users and clobber these options via
sudo/su/env and similar wrappers, so I think it has to do with how
you're starting unicorn.  If you're using sudo anywhere, the env_*
options from the sudoers files will also affect which envs get
clobbered/preserved/added.

> From what I can tell, that its unicorn is the only
> thing thats different versus running the same ruby via a rails console
> (which does indeed set those shell variables correctly)
> 
> in no mans land, so any hep or insight would be greatly appreciated. 

Can you add something to log the contents of ENV.inspect to
a log file.  Perhaps something like:

	Rails.logger.debug("env: #{ENV.inspect}")

It would also be helpful to show the snippet of code from where you're
running Rake in case you're accidentally setting an option wrong.


Under Linux, you can also inspect the original environment of any running
process from /proc/$PID/environ  In most cases/kernel versions, it won't
keep up with env changes once a process is running.
I use tr to replace '\0' with '\n' (newline) to help with readability

	tr '\0' '\n' </proc/$PID/environ

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-27 18:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27 14:32 $USER and $HOME shell variables not set Russell Jennings
2015-03-27 18:34 ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).