tinted-theming / tinted-shell

Base16 and Base24 for Shells
https://github.com/tinted-theming/home
MIT License
65 stars 217 forks source link

Fix permission issue on tmux.conf #7

Closed mattdavis90 closed 2 years ago

mattdavis90 commented 2 years ago

Since the introduction of hooks I am now getting the following error when starting a new terminal - without having custom config paths set - looks like it is down to the variable checking in bash.

home/user/.zplug/repos/base16-project/base16-shell/hooks/base16-tmux.sh: line 30: /tmux.base16.conf: Permission denied
belak commented 2 years ago

We'll have to figure out what the underlying cause is - I don't think this fix is correct because it reverses a few checks which look like they're designed to set variables to default variables if they're not already set (hence the -z).

I'm guessing that BASE16_CONFIG_PATH isn't set for some reason.

CC @JamyGolden

JamyGolden commented 2 years ago

Looking into what could be the issue now.

JamyGolden commented 2 years ago

@mattdavis90 can you use the main branch of base16-shell and not this PR. Then echo $BASE16_CONFIG_PATH. What value are you getting? you should be getting /home/mattdavis90/.config/base16-project.

If you want more real-time problem solving of this issue, I'm on #base16 on Libera.Chat IRC (https://libera.chat/), but I'm happy to do it over the PR too.

belak commented 2 years ago

It may also be a zplug specific issue - I seem to remember it caching environment variables so maybe it's missing some, now that we've changed this repo. Alternatively maybe it's resetting the environment somewhere.

JamyGolden commented 2 years ago

Also what operating system and shell are you using? How are you loading up base16-shell/profile_helper.sh?

mattdavis90 commented 2 years ago

Reverting to main and adding this into the hook before and after each if statement

echo "1 "$BASE16_SHELL_TMUXCONF_PATH
echo "2 "$BASE16_CONFIG_PATH
echo "3 "$BASE16_TMUX_PLUGIN_PATH

yields the following on a new terminal

1 
2 /home/matt/.config/base16-project
3 
1 /home/matt/.config/base16-project/tmux.base16.conf
2 /home/matt/.config/base16-project
3 
1 /home/matt/.config/base16-project/tmux.base16.conf
2 /home/matt/.config/base16-project
3 /home/matt/.tmux/plugins/base16-tmux
1 
2 
3 
1 /tmux.base16.conf
2 
3 
1 /tmux.base16.conf
2 
3 /home/matt/.tmux/plugins/base16-tmux
/home/matt/.zplug/repos/base16-project/base16-shell/hooks/base16-tmux.sh: line 42: /tmux.base16.conf: Permission denied

So looks like the hook is running twice for some reason and the second time round $BASE16_CONFIG_PATH isn't set.

I'm using zplug in my .zshrc as so

zplug "base16-project/base16-shell", use:"base16-shell.plugin.zsh", from:github

I don't have any explicit calls to base16-shell/profile_helper.sh

I'm not available to IRC right not but may be around tomorrow. Thanks

JamyGolden commented 2 years ago

Hmm, I'm wondering if there is a difference between this running for the first time and when you use the alias. Do you get the same result when you run either of the following:

  1. base16_ayu-dark
  2. Make sure you have $BASE16_THEME_DEFAULT="ocean" set in your zshrc and then rm -rf ~/.config/base16-project and open a new terminal window or source the zshrc.
mattdavis90 commented 2 years ago

On an already existing shell with a theme already running, if I run base16_ayu-dark then I get the following output

1 
2 /home/matt/.config/base16-project
3 
1 /home/matt/.config/base16-project/tmux.base16.conf
2 /home/matt/.config/base16-project
3 
1 /home/matt/.config/base16-project/tmux.base16.conf
2 /home/matt/.config/base16-project
3 /home/matt/.tmux/plugins/base16-tmux

Setting a default and removing .config then opening a new terminal, I get

1 
2 /home/matt/.config/base16-project
3 
1 /home/matt/.config/base16-project/tmux.base16.conf
2 /home/matt/.config/base16-project
3 
1 /home/matt/.config/base16-project/tmux.base16.conf
2 /home/matt/.config/base16-project
3 /home/matt/.tmux/plugins/base16-tmux
1 
2 
3 
1 /tmux.base16.conf
2 
3 
1 /tmux.base16.conf
2 
3 /home/matt/.tmux/plugins/base16-tmux
/home/matt/.zplug/repos/base16-project/base16-shell/hooks/base16-tmux.sh: line 42: /tmux.base16.conf: Permission denied

So looks like it runs twice, and the second time $BASE16_CONFIG_PATH isn't set. Setting any base16 theme afterwards works as expected. It is just on the first import of the script that this happens.

mattdavis90 commented 2 years ago

I've just changed out the zplug line in the my .zshrc for the following

. ~/.zplug/repos/base16-project/base16-shell/profile_helper.sh

and that stops the helper being run twice. It looks as though something is going a little wrong in the zplug load

JamyGolden commented 2 years ago

Ah ok, I have an idea to fix this. Can you try out this base16-shell branch? jamy/bugfix/double-loading-plugin.

The branch doesn't set the theme if it's already been set (i.e. if $BASE16_THEME has already been set)

mattdavis90 commented 2 years ago

That seems to be working correctly. Thanks

JamyGolden commented 2 years ago

Ok nice, I'll update/hijack this branch PR so we have this all linked to the chage.

JamyGolden commented 2 years ago

Ah you've done it through a fork. Ok I'll create a new PR and link to this. Btw you should be able to push branches directly to all repos in base16-project since you're in the org (so you shouldn't need to use the fork if you don't want).

mattdavis90 commented 2 years ago

Good to know, thanks. I wasn't sure what permission I had on the other repos.

JamyGolden commented 2 years ago

https://github.com/base16-project/base16-shell/pull/8