Pull request page doesn't show up but opening finder instead
Describe the bug
When I press the key 'o' or 'O' to open the pull request page right from Lazygit, it only open the Finder instead of opening pull request page in a default browser.
To Reproduce
Steps to reproduce the behavior:
- Open Lazygit
- Go to section 3 - Local branches
- Select an opening local branch then press 'o' or 'O' to select the target branch.
- It goes to finder of that repository's directory instead of opening pull request page.
Expected behavior
Opening pull request page in a default browser.
Version info:
-
Run
lazygit --versionand paste the result here commit=, build date=, build source=Homebrew, version=0.56.0, os=darwin, arch=arm64, git version=2.51.2 -
Run
git --versionand paste the result here git version 2.51.2
Additional context
Device: Macbook Pro M1pro with MacOS Tahoe 26.0.1
[!NOTE] I tried copying the pull request URL with command
Ctrl + yand it gets the correct pull request URL once I try pasting and enter in a browser.
Could you please check the command log? Press @ to focus it and see what happens after you try opening a PR?
It's supposed to run open <url> which should use your default browser to open it, you can also try running open https://github.com/jesseduffield/lazygit/ from the terminal to see if it works.
Here is what I got from log once I pressed 'o'
Open pull request in browser
/bin/zsh -c "open "$(echo ""https://git.company.net/path/to/project/repo/-/merge_requests/new?merge_request%5Bsource_branch%5D=dev"" | sed 's/%2F/\//g')""
@PoomKrit
In my lazygit config, and maybe in yours too, is
os:
openLink: open "$(echo "{{link}}" | sed 's/%2F/\//g')"
following a workaround suggested in #3064.
That used to work fine but since upgrading lazygit I had the same issue as you: it opens finder, not browser.
The fix: I removed the quotes around {{link}}
os:
openLink: open "$(echo {{link}} | sed 's/%2F/\//g')"
and now it works again.
I haven't dug into what changed. But if I run just the subcommand from your example in zsh it errors:
% echo ""https://git.company.net/path/to/project/repo/-/merge_requests/new?merge_request%5Bsource_branch%5D=dev"" | sed 's/%2F/\//g'
zsh: no matches found: https://git.company.net/path/to/project/repo/-/merge_requests/new?merge_request%5Bsource_branch%5D=dev
I guess that's because zsh pairs the two quotes "" at the start of the link, taking them to quote an empty string, and the same for the ones at the end of the link, so it's the same as if no quotes at all, so the ? in the link is taken as a glob pattern, but no file matches it. Thus the error.
A simpler example:
% echo ""foo""
foo
% echo ""foo?""
zsh: no matches found: foo?
Anyway, I'm not sure why it worked with the two quotes before and not now, or why lazygit is opening the project in the finder.
Thanks @cosmo-grant
I just realized it today before coming to see your comment, which is almost a week ago, that the issue is from that part.
I really did configure that in my lazygit/config.yml and once I removed it, it works as it should be now 😄