0
votes

I'm working intensively with pipenv (Python) and tmux. Each of my projects has its own pipenv environment and I like starting tmux within this environment, e.g., running the following command:

pipenv run tmux

This works fine for the first project where I run this command. But as soon as I run it for a second project (while the first tmux session is still active), new panes in the second tmux session will start with the pipenv environment from the first tmux session.

To be precise: the problem does not occur for the initial pane of the second tmux session, but only when I open new panes.

Any ideas?

1

1 Answers

1
votes

The global environment is set up when the tmux server is started and that is used for all panes, presumably pipenv needs some stuff to be different in the environment. You will need to figure out what it expects to be set.

Then you have a few options:

  • Use -L to use different tmux servers instead of different tmux sessions, so each one has the environment where it was started from. You will probably end up with many tmux servers however.

  • Put whatever pipenv needs into the tmux update-environment option so it is copied into the session environment when the session is created. Note it will also be copied on attach as well (but obviously that will only affect panes created after attach).

  • Configure the environment inside tmux yourself in new panes, how you do this will depend what features pipenv has available. I don't know that. If it is just one environment variable it would probably be pretty easy.

new-window and split-window have a -e flag to explicitly set environment variables, but unfortunately that was never extended to new-session as well. You could still perhaps make a second window with -e and then kill the first window.