-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove print_source_bashrc property #9516
base: master
Are you sure you want to change the base?
Conversation
Note that this will not run if you just call |
This will be pretty verbose on the containers because they print |
Ah-- this hangs the unit tests, because we start a new shell. hm |
ed48d11
to
ed0eb6d
Compare
97305c9
to
c66a4f6
Compare
306c67a
to
e3c2fe6
Compare
Fixed-- set |
9cacceb
to
05506b1
Compare
Sorry for late response😅 I don't think this is a good approach, as it will spawn "nested" shells after each If I remember correctly, you cannot simply kill the parent shell as it will cause the crosh window close immediately. FYI chromebrew/crew-profile-base#6 was my previous attempt on auto-sourcing bashrc after |
Yeah, the additional shells aren't great, but this is the best solution I could find. Ideally, we'd just replace the shell process that spawned crew, but we can't do that if it'll kill the crosh window. In theory, could we spawn one additional shell process, then continuously replace that? |
I'm sure there's a way to check if there have been any changes in the environment that need to be sourced (i.e. try starting a new shell and check if its environment setup is the same as the old one), and then we could only start a new shell based off of that? That wouldn't eliminate the problem of additional shells, but it would drastically reduce it. |
The window will not close if we run
Why we need to replace the shell at all :) If we can run
We can use something like |
The problem is that we can't run |
Although we cannot call We can use # Add this line to /usr/local/etc/profile (crew-profile-base)
trap "source ~/.bashrc" USR1 In Process.kill('USR1', Process.ppid) |
Don't we sometimes source /usr/local/etc/profile from ~/.bashrc? This would create a loop... |
No, as the trap will trigger once only (and only when) after someone try to |
@Zopolis4 How do you feel about modifying this PR to use |
Signed-off-by: Satadru Pramanik <satadru@gmail.com>
I got it to work! Try this in a container:
|
In #9649 I'm just execing a shell at the end of the crew process if the trap isn't set... but that should only happen once, I think. |
(If that's ok, you should be able to merge master and use 95% of the changes here...) |
I would like to merge #9649 into this. I don't think But I think the essence of that would be helpful in multiple places, maybe as a zsh not working ought to be a separate bug... but also, if nobody uses it... maybe we should also just mark is as broken... maybe somebody wants to take that up as their own project. |
Updated and rebased to only have the removal of |
@@ -130,6 +130,8 @@ at_exit do | |||
|
|||
# Print exit messages. | |||
ExitMessage.print | |||
# Replace the currently running Ruby process with a new instance of the parent shell (thus sourcing the relevant configuration) | |||
exec(`ps -p #{Process.ppid} -o comm=`.chomp) unless CREW_SCRIPTING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump crew version in lib/const.rb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops that's leftover code from the old approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this approach doesn't work, right? So do we need to just rename the print_source_bashrc line with something else since the autosource PR handles this? Maybe 's/print_source_bashrc/source_bashrc/'
or 's/print_source_bashrc/autosource_bashrc/'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we just want to source bashrc after every install?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this approach does work, but @supechicken was worried about the memory costs of opening a new bash process every time crew was run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that not harder to do?
You check the latest file modification timein/usr/local/etc/env.d/
, compare it with current, and done. Shouldn't be too bad. At any rate, I'm trying to avoid repeating lots of code in package files, and this is a good place to improve.
And how do you know if ~/.bashrc has been sourced yet at all?
Not really sure what you mean here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And how do you know if ~/.bashrc has been sourced yet at all?
Not really sure what you mean here.
Sometimes we want to make sure that the bashrc is sourced after the crew command, irrespective of whether files have changed in env.d (because scripts there might change some state when being run again, even if the scripts themselves haven't changed.)
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so? We can set it up to source after every command, but we currently don't. If we want to do it unconditionally, it shouldn't be too hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a middle ground where we don't want the running to be unconditional. See for instance the bash scripts for distcc.
We don't need those run after every single crew command. They only need to be run after distcc is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but they can be run after every shell invocation... That's fine... If run with every crew command we will essentially get logspam with every crew command.)
cd ~ | ||
git clone --depth=1 https://github.com/chromebrew/chromebrew.git | ||
cd chromebrew | ||
yes | crew build -f packages/hello_world_chromebrew.rb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need this to be yes | CREW_CACHE_ENABLED=1 crew build -f packages/hello_world_chromebrew.rb
to get the unit test to pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into this further, setting CREW_CACHE_ENABLED=1
just papers over the bug that crew build
is actually broken as it attempts to install packages after they are built, despite new binaries not having been uploaded-- we probably shouldn't be silencing bugs in our unit tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a bug. That's intentional.
Installing just built packages as part of a sequence of building multiple interdependent packages is an intentional feature of the -f
flag to crew build
in that context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise you can't test if a just built package installs correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that code fails by default if CREW_CACHE_ENABLED is not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I enable have CREW_CACHE_ENABLED=1
in all of my builds...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're right, we should have this work without that...
Just checking I've got the right understanding here, but we now |
The "trick" is to use
exec()
to replace the ruby process with a new instance of the parent shell on exit, which sources the relevant configuration file(s).Tested and working on
x86_64
with bothbash
andfish
-- I couldn't getzsh
working (at all) in the container, so that hasn't been tested.Also, given that we don't need it anymore, I removed
print_source_bashrc
and the handling around that, as well as any other leftover calls toputs source ~/.bashrc
and the like.Run the following to get this pull request's changes locally for testing.