hschmidt/EnvPane

Doesn't work after restart with "Reopen existing applications"

jgogstad opened this issue · 10 comments

Admittedly not the greatest of errors, but it just caused some confusion. If you see any way to fix it, it would be nice.

To recreate

  1. Set a variable in EnvPane
  2. Open iTerm
  3. Restart computer and check the checkbox for restarting all applications
  4. When computer restarts, the iTerm application no longer see the variables set in EnvPane

Workaround: Restart iTerm

What version of EnvPane are you using. Did you download the official release or
did you build it yourself?

Latest official, 0.6

What version of OS X are you using (or attempting to use) EnvPane on?

Sierra

Did you install EnvPane for the current user only or for all users? I admit,
that's a bit of a trick question.

Current user only

Did you install EnvPane as an administrative user?

No

Can you provide relevant system.log messages? You can use the Console
application to get those: Hit Cmd-Space, type Console, hit enter (the Console
app should open), click on system.log on the left, click the search bar at
the top and type Env to filter the list. Copy and paste it below but be sure
to redact any confidential informations such as account names, IP addresses etc.

Yes, having the same issue, extremely annoying.

Is there some way to prioritize the execution of EnvPane on startup?

This is sort of a big one, any idea how to resolve this?

I agree. I am not sure how to fix the race between the agent and other apps being started automatically.

EnvPane uses a launch agent to run it's script. Would it be possible to use a launch daemon instead? It sounds like those run without the user even being logged in, so I'm wondering if it's possible for it to inject the environment changes earlier in the lifecycle, before the applications startup during login?

http://krypted.com/mac-security/mac-os-x-launch-daemons-vs-launch-agents/

When it isn't working is there a way to recover, by forcing the launch agent to run again or something?

This was pretty confusing for me as well. Took a few "WTF" moments after restarts for updates before I realised this was happening. Has anyone experimented with solutions?

If the automatically reopened applications are restarted, does that set the variables for them or is a full reboot without automatically reopening running applications required?

@hschmidt I'll test the "full reboot" scenario tonight if you need, from what I can tell, the situation is when you do the reboot and have "reopen my apps", the operating system appears to do something differently that leads to the environment variables not being set when terminal (or other) applications are relaunched.

My gut is telling me this might be a race condition or that the way Apple launches applications after a restart is causing them to be loaded before EnvPane gets a chance to set the variables, since simply exiting the application and starting it again always fixes it for me.

I'll test the "full reboot" scenario tonight if you need

That won't be necessary given that you report that

simply exiting the application and starting it again always fixes it for me

It's probably a simple race condition like you and others suspect. It's been a while since I worked on EnvPane and I don't remember whether I chose to use an agent instead of a daemon simply because an agent seemed to be the more appropriate option or whether there was a different reason. It's possible that while daemons are launched before apps, they might not have the ability to set environment variables on the session the apps are launched in, because they run in their own separate session.