Closed mastoj closed 2 years ago
@mastoj Thanks for filing, and sorry you're having some trouble!
Can you verify that:
1) You symlinked /path/to/iterm-components/kubectl_context.py
to ~/Library/Application\ Support/iTerm2/Scripts/AutoLaunch/kubectl_context.py
and that it's selected in the Scripts -> AutoLaunch menu
2) kubectl context
shows up in the list of components in Preferences -> Profiles -> Session -> Configure Status Bar
Additionally, can you see if one/any of the other components work? The hello_world.py
component in particular would be a good starting place, because it doesn't do anything based dynamically on your shell.
Let me know, and we'll see if we can get you sorted!
@daneah, I had already tried those things and it worked :). I even pulled up the iTerm REPL and tried to execute https://github.com/daneah/iterm-components/blob/master/kubectl_context.py#L18-L23 manually, and that is when I got the feedback on missing kubectl (I should probably have provided that information at start).
I don't know in what context the REPL is running, is it the same as for when the scripts are executed?
Also, if I use the absolute path it does work, but that is annoying :)
Understood! Is kubectl
located in the usual place (/usr/local/bin/kubectl
) and, more importantly, somewhere that's on your $PATH
? I haven't run into this so I'm also trying to debug in my own head π
Yes, the regular place and it is in my path when open bash or zsh. Itβs not in the path when I open the iterm repl it seems.
On Tue, 6 Aug 2019 at 15:57, Dane Hillard notifications@github.com wrote:
Understood! Is kubectl located in the usual place (/usr/local/bin/kubectl) and, more importantly, somewhere that's on your $PATH? I haven't run into this so I'm also trying to debug in my own head π
β You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/daneah/iterm-components/issues/12?email_source=notifications&email_token=AAD2NMBFXKBSO37Q7EGW5JDQDF7LFA5CNFSM4IJO6VTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3VHATI#issuecomment-518680653, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2NMB5C3RS23I2U5UZ4ATQDF7LFANCNFSM4IJO6VTA .
So I wasn't aware of the iTerm2 REPL feature. After trying it, the REPL also doesn't know about kubectl
on my machine. The REPL appears to run in a different context than the AutoLaunch scripts, which appear to run in an interactive login shell. Can you try this?
First, remove the scrpit from AutoLaunch:
$ rm ~/Library/Application\ Support/iTerm2/Scripts/AutoLaunch/kubectl_context.py
Then restart iTerm2 and try running it manually:
$ cd /path/to/iterm-components/
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install iterm2
$ python kubectl_context.py # this should bring up an "API access request" window
Let me know how this behaves.
Didn't work:
Traceback (most recent call last): File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/connection.py", line 284, in async_connect await coro(self) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/connection.py", line 171, in async_main await coro(connection) File "kubectl_context.py", line 22, in main await component.async_register(connection, kubectl_context_coroutine) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/statusbar.py", line 208, in async_register await coro.async_register(connection, self) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/registration.py", line 238, in async_register status_bar_component=component) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/notifications.py", line 315, in async_subscribe_to_server_originated_rpc_notification rpc_registration_request=rpc_registration_request) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/notifications.py", line 434, in _async_subscribe raise SubscriptionException(iterm2.api_pb2.NotificationResponse.Status.Name(status)) iterm2.notifications.SubscriptionException: DUPLICATE_SERVER_ORIGINATED_RPC Traceback (most recent call last): File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/protocol.py", line 795, in transfer_data message = await self.read_message() File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/protocol.py", line 863, in read_message frame = await self.read_data_frame(max_size=self.max_size) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/protocol.py", line 938, in read_data_frame frame = await self.read_frame(max_size) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/protocol.py", line 1018, in read_frame extensions=self.extensions, File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/framing.py", line 121, in read data = await reader(2) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/streams.py", line 672, in readexactly raise IncompleteReadError(incomplete, n) asyncio.streams.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/connection.py", line 130, in _async_dispatch_forever data = await self.websocket.recv() File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/protocol.py", line 484, in recv await self.ensure_open() File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/websockets/protocol.py", line 771, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
I think the above was due to the fact that I had the coroutine registered twice or something. Cleaned that up but it still doesn't work. It just hangs forever it seems. I cancelled it with ctrl-c and the following stack trace was written:
β iterm-components git:(master) python3 kubectl_context.py ^CTraceback (most recent call last): File "kubectl_context.py", line 28, in
iterm2.run_forever(main) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/connection.py", line 343, in run_forever Connection().run_forever(coro, retry, debug) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/connection.py", line 114, in run_forever self.run(True, coro, retry, debug) File "/Users/tomasjansson/git/mastoj/iterm-components/.venv/lib/python3.6/site-packages/iterm2/connection.py", line 181, in run loop.run_until_complete(self.async_connect(async_main, retry)) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 471, in run_until_complete self.run_forever() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 438, in run_forever self._run_once() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 1415, in _run_once event_list = self._selector.select(timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/selectors.py", line 577, in select kev_list = self._kqueue.control(None, max_ev, timeout) KeyboardInterrupt
It's supposed to run forever π if you start it running, you should be able to add the status bar component and see the output of kubectl
as the value.
So that is how it works... I'll try that.
Running it like that actually works... so for some reason it doesn't pick up my environment when running through AutoLaunch.
I'm afraid I'm not sure what else could be going on. Mine runs properly the manual way, and then when I add it to AutoLaunch it shows up as below and continues to work π
strange, mine shows up but for some reason the path when running doesn't seem to be correct.
I see two potential fixes for it:
On Tue, Aug 6, 2019 at 10:35 PM Dane Hillard notifications@github.com wrote:
I'm afraid I'm not sure what else could be going on. Mine runs properly the manual way, and then when I add it to AutoLaunch it shows up as below and continues to work π
[image: Screenshot 2019-08-06 16 34 04] https://user-images.githubusercontent.com/1808306/62575185-306bee00-b868-11e9-8d50-e7285e787b18.png
β You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/daneah/iterm-components/issues/12?email_source=notifications&email_token=AAD2NMAXW7L2D46BY52P7Q3QDHOBHA5CNFSM4IJO6VTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3WMKYY#issuecomment-518833507, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2NMHENKR2MD3THERPE7DQDHOBHANCNFSM4IJO6VTA .
Does the generic_command
, when passed kubectl config current-context
, yield you the proper result? I'd be thoroughly perplexed by that as they seem equivalent! Unless you're including the full path to the command there? I'm able to pass just the command without a path. You could debug this a bit by using which kubectl
as your arbitrary command π
Nope, I have to give the full path. But now I can at least define what it should be :)
On Tue, 6 Aug 2019 at 23:54, Dane Hillard notifications@github.com wrote:
Does the generic_command, when passed kubectl config get-context, yield you the proper result? I'd be thoroughly perplexed by that as they seem equivalent! Unless you're including the full path to the command there?
β You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/daneah/iterm-components/issues/12?email_source=notifications&email_token=AAD2NMFDPABRXYL5QZUJDMLQDHXJNA5CNFSM4IJO6VTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3WSNTY#issuecomment-518858447, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2NME432W26PHPXKZDLDTQDHXJNANCNFSM4IJO6VTA .
@mastoj I just tried echo "$PATH"
as a generic command and was surprised to see that my $PATH
was not the same as it is in my interactive login shell. Even which kubectl
turned out to return nothing! But it still knows what kubectl
is because it has /usr/local/bin
in the path.
Iβm about to go to bed here :). You could try which kubectl
as a generic
command as well to see where it picks it up.
On Wed, 7 Aug 2019 at 00:20, Dane Hillard notifications@github.com wrote:
@mastoj https://github.com/mastoj I just tried echo "$PATH" as a generic command and was surprised to see that my $PATH was not my interactive login path. Even which kubectl turned out to return nothing! But somehow, it still knows what kubectl is π€
β You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/daneah/iterm-components/issues/12?email_source=notifications&email_token=AAD2NMDUB6DCQ6IBJSKDWI3QDH2K3A5CNFSM4IJO6VTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3WUD4Y#issuecomment-518865395, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2NMCGZ4OZWDX32G3P2XLQDH2K3ANCNFSM4IJO6VTA .
No worries, speak to you tomorrow maybe! As above, the which kubectl
returns empty string for me.
do you get empty string if you do echo $(which kubectl)
as well (should be the same as running which kubectl
though)
Really strange that you get empty string but it still works for you :)
Yeah I tried this too, with the same result! Not sure what to make of it.
Neither am I, it is not critical for me to get it fixed since I can just use the generic one for now. It would be interesting to know what is going on though, but have other things I must prioritize.
On Wed, Aug 7, 2019 at 11:23 PM Dane Hillard notifications@github.com wrote:
Yeah I tried this too, with the same result! Not sure what to make of it.
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/daneah/iterm-components/issues/12?email_source=notifications&email_token=AAD2NMDWPXYS3Y6J2YKIXTTQDM4OJA5CNFSM4IJO6VTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3ZX67Y#issuecomment-519274367, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2NMH5JA3OGFGNCWDOEVDQDM4OJANCNFSM4IJO6VTA .
I'll keep this open and explore where I can π
Not much for me to do since it is on your machine it is inconsistent. I
really don't understand why it works for you when which kubectl
returns
""
.
On Thu, Aug 8, 2019 at 3:17 PM Dane Hillard notifications@github.com wrote:
I'll keep this open and explore where I can π
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/daneah/iterm-components/issues/12?email_source=notifications&email_token=AAD2NMFF6UIJ7NFGESNS74TQDQMEZA5CNFSM4IJO6VTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD33SLCA#issuecomment-519513480, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2NMC4RPOI43UKRCEVOALQDQMEZANCNFSM4IJO6VTA .
Great stuff you have going here, I just need to get it working :)
I want the kubernetes context in my status bar, but it is just blank. My guess is that the script is running in some weird context so it doesn't have access to kubectl.
Is there a way to verify my assumption? Do you know how to fix it?