updating the env

31 views
Skip to first unread message

tcurdt

unread,
Aug 17, 2012, 2:38:59 PM8/17/12
to babush...@googlegroups.com
I have a dep that creates a file in "/etc/profile.d" which updates the PATH but since the file does not get sourced the "in_path?" check fails.
Not really sure how to update the environment.

Any thoughts how to do this?

Ben Hoskings

unread,
Nov 19, 2012, 4:42:50 AM11/19/12
to babush...@googlegroups.com
This message slipped through the cracks of my inbox, sorry :)

Is this still a problem?

- Ben
> --
> To post, email babush...@googlegroups.com
> To unsubscribe, email babushka_app...@googlegroups.com
> ~
> http://babushka.me
> http://github.com/benhoskings/babushka
> http://groups.google.com/group/babushka_app

Torsten Curdt

unread,
Nov 19, 2012, 6:50:47 AM11/19/12
to babush...@googlegroups.com
Unfortunately that's still a big problem. You never run into this before?

cheers,
Torsten

Paul Annesley

unread,
Nov 19, 2012, 10:02:26 PM11/19/12
to babush...@googlegroups.com
So you have something along these lines? (pseudocode-ish)

met? { ENV["PATH"].contains?("/some/dir") }
meet { write_file_which_sets_path("/etc/profile.d/something") }

I would never expect writing a file to disk to change the ENV of a running process.

Can your `met?` block start a sub-shell which would load /etc/profile.d files and check for the correct $PATH?
It might need to be a login shell…?

— Paul

Ben Hoskings

unread,
Nov 20, 2012, 3:44:51 AM11/20/12
to babush...@googlegroups.com
Yep, I'd start a subshell. You should be able to do this with #login_shell.

I have a dep that achieves a similar purpose here:

https://github.com/conversation/babushka-deps/blob/master/env.rb

- Ben

Torsten Curdt

unread,
Nov 20, 2012, 8:22:59 AM11/20/12
to babush...@googlegroups.com
It's my rbenv dep here

https://github.com/tcurdt/babushka-deps/blob/master/rbenv.rb

So maybe I just need to replace "shell" with "login_shell" then?
Will give that a try.

Ben Hoskings

unread,
Nov 26, 2012, 7:06:55 PM11/26/12
to babush...@googlegroups.com
Hi Torsten, how'd you go with this?

- Ben

Torsten Curdt

unread,
Nov 27, 2012, 10:10:40 AM11/27/12
to babush...@googlegroups.com
Thanks for checking - using "login_shell" did the trick. Still a few things to improve though. Is there a 
raw_login_shell as well? (to handle stdout etc)

Right now I am also using login_shell to check for the path - not ideal.

Ben Hoskings

unread,
Dec 22, 2012, 5:24:41 AM12/22/12
to babush...@googlegroups.com
There isn't. There are a few combinations of shell methods missing -- for example, there are #shell! and #log_shell, but no #log_shell!.

Perhaps I should refactor some of those modified shell methods to be option-driven instead.

- Ben

Torsten Curdt

unread,
Dec 26, 2012, 6:27:11 PM12/26/12
to babush...@googlegroups.com
+1

find it quite confusing what is available and what is not

Ben Hoskings

unread,
Jan 25, 2013, 10:40:08 PM1/25/13
to babush...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages