Skip to content
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

[choco fzf] FZF log errors #494

Closed
louiss0 opened this issue Aug 29, 2024 · 18 comments
Closed

[choco fzf] FZF log errors #494

louiss0 opened this issue Aug 29, 2024 · 18 comments

Comments

@louiss0
Copy link

louiss0 commented Aug 29, 2024

ble version: 0.4.0-devel4+75c4a84
Bash version: 5.2.21(1)-release
I get errors in my console that look like this

ble/contrib/integration:fzf: failed to find "fzf" base directory
ble/contrib/integration:fzf: failed to find "fzf" base directory
ble/contrib/integration:fzf: failed to find "fzf" base directory

This is when I start. But the code still works I'm able to use ble.sh with fzf.

To start you need to download Cygwin and use the defaults.

Then download fzf fd and zoxide using choco

choco install  -y fzf fd zoxide

Then download basher.

curl -s https://raw.githubusercontent.com/basherpm/basher/master/install.sh | bash

Then use basher to download ble.sh

basher install akinomyoga/ble.sh

Then clone this repo.

git clone https://github.com/louiss0/blesh_setup  .

This folder comes with the .config/ folder that I used. It also comes with a .bashrc file.
Just move the files to the root if the bash rc file exists just copy the code from the cloned repo and put it in there.

@akinomyoga
Copy link
Owner

The problem seems to be that the Cygwin package doesn't include the necessary files:

The files are distributed by independent packages:

but these will forcibly load the settings in Bash, so it's even worse for ble.sh.

Then, you need to manually prepare these files. You can download the settings from the upstream fzf repository (please be careful to download the settings for the same version of fzf. Cygwin fzf packages seem to be using 0.12.1):

and put is somewhere (such as ~/.config/fzf/shell/{completion,key-bindings}.bash and set the variable _ble_contrib_fzf_base=~/.config/fzf before the calls of `ble-import' as described here

@louiss0
Copy link
Author

louiss0 commented Aug 29, 2024

I downloaded fzf from choco?
I didn't know there was a package in cygwin

@akinomyoga
Copy link
Owner

OK, I thought you were talking about the Cygwin version of fzf installed through choco since you've specified Cygwin. There seems to be also the fzf package from the Chocolatey repository:

However, the detailed content of the package does not seem to be available on the above site. Then, I set up choco and actually tried choco install fzf. Although the Bash package doesn't seem to exist in the Chocolatey repository, the Chocolatey version of fzf seems to be visible from Cygwin Bash at C:\ProgramData\chocolatey\bin:

$ type -a fzf
fzf is /usr/bin/fzf
fzf is /bin/fzf
fzf is /cygdrive/c/ProgramData/chocolatey/bin/fzf

However, the related files still do not seem to be installed by Chocolatey's fzf package:

$ tree /cygdrive/c/ProgramData/chocolatey
/cygdrive/c/ProgramData/chocolatey/
├── CREDITS.txt
├── LICENSE.txt
├── bin
│   ├── RefreshEnv.cmd
│   ├── _processed.txt
│   ├── choco.exe
│   └── fzf.exe
├── choco.exe
├── choco.exe.ignore
├── choco.exe.manifest
├── config
│   ├── chocolatey.config
│   └── chocolatey.config.backup
├── helpers
│   ├── Chocolatey.PowerShell.dll
│   [...snip...]

├── lib
│   ├── chocolatey
│   │   └── chocolatey.nupkg
│   └── fzf
│       ├── fzf-0.53.0-windows_amd64_x32.zip.txt
│       ├── fzf.nupkg
│       ├── fzf.nuspec
│       ├── legal
│       │   ├── LICENSE.txt
│       │   └── VERIFICATION.txt
│       └── tools
│           ├── chocolateyInstall.ps1
│           └── fzf.exe
├── logs
│   ├── choco.summary.log
│   └── chocolatey.log
├── redirects
│   ├── RefreshEnv.cmd
│   ├── choco.exe
│   └── choco.exe.ignore
└── tools
    ├── 7z.dll
    ├── 7z.dll.manifest
    ├── 7z.exe
    ├── 7z.exe.ignore
    ├── 7z.exe.manifest
    ├── 7zip.license.txt
    ├── checksum.exe
    ├── checksum.exe.config
    ├── checksum.exe.ignore
    ├── checksum.license.txt
    ├── shimgen.exe
    ├── shimgen.exe.ignore
    └── shimgen.license.txt

@akinomyoga
Copy link
Owner

I left a request in the Chocolatey package.

@akinomyoga akinomyoga changed the title FZF log errors [choco fzf] FZF log errors Sep 3, 2024
@akinomyoga
Copy link
Owner

Maintainers of the fzf package on the Chocolatey repository haven't replied so far. I left another comment on the package page. If they don't respond for several days, I'll send a direct message to the maintainers.

@louiss0
Copy link
Author

louiss0 commented Sep 9, 2024

Maintainers of the fzf package on the Chocolatey repository haven't replied so far. I left another comment on the package page. If they don't respond for several days, I'll send a direct message to the maintainers.

It's OK

@akinomyoga
Copy link
Owner

Thanks for your patience.

@akinomyoga
Copy link
Owner

akinomyoga commented Sep 9, 2024

I actually anticipate there will be more packages in the future that are missing the shell integration files because the upstream fzf started to support the option --bash (junegunn/fzf#3675). If a package maintainer closely looks at README of fzf, they should notice that it still instructs the users to use the shell integration files for finer control, but careless maintainers would miss the description and may think as if they wouldn't need to ship the shell integration files anymore.

Although it might increase the initialization cost, I'll later add a fallback for the case where the package maintainers didn't include the corresponding files.

@akinomyoga
Copy link
Owner

There is still no response from the maintainers of the Chocolatey package for fzf.

Nevertheless, I added a workaround in akinomyoga/blesh-contrib@5aff5f6. When the shell settings are not found in the system and the fzf version is 0.48.0 or above, ble.sh attempts to get the shell settings by running fzf --bash. If possible, it is still better to use the shell script files due to the overhead with fzf --bash, but now at least the error message would not arise.

@louiss0 Could you check the behavior?


For the Chocolatey package, I found the maintainer's repository that contains the setup for the fzf package, but it seems to be just downloading a Windows binary from the upstream fzf's release page. However, those binary files in the upstream release page seem to be used in a part of the official installation process and do not seem to comprise the full installation data.

@louiss0
Copy link
Author

louiss0 commented Sep 27, 2024

There is still no response from the maintainers of the Chocolatey package for fzf.

Nevertheless, I added a workaround in akinomyoga/blesh-contrib@5aff5f6. When the shell settings are not found in the system and the fzf version is 0.48.0 or above, ble.sh attempts to get the shell settings by running fzf --bash. If possible, it is still better to use the shell script files due to the overhead with fzf --bash, but now at least the error message would not arise.

@louiss0 Could you check the behavior?

For the Chocolatey package, I found the maintainer's repository that contains the setup for the fzf package, but it seems to be just downloading a Windows binary from the upstream fzf's release page. However, those binary files in the upstream release page seem to be used in a part of the official installation process and do not seem to comprise the full installation data.

I'm sorry for taking so long. I was trying out nushell while I was gone.
I decided to switch to using winget as my package manager.
It seems to work out.

@louiss0
Copy link
Author

louiss0 commented Sep 27, 2024

Now I have a new error when I try to integrate it with fzf.
I try to use the .blerc file but I can't seem to load the fzf integration.

This is the .bashrc file.
With irrelavant information stripped out or course.

# If not running interactively, don't do anything



#~ Initilization Conditions

[[ "$-" != *i* ]] && return

# bashrc

# Add this lines at the top of .bashrc:
[[ $- == *i* ]] && source ~/.basher/cellar/packages/akinomyoga/ble.sh/out/ble.sh --noattach



# Use bash-completion, if available
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
    source /usr/share/bash-completion/bash_completion

export CYGWIN_HOME_PATH=$(cygpath ~ -m) 
    
#~## FZF

show_file_or_dir_preview="if [[ -d {} ]]; then eza --icons --tree -a --level=3 {} | head -200; else bat -n --color=always --line-range :500 {}; fi"


#~### Variables
export FZF_DEFAULT_COMMAND="fd --path-separator=/ --hidden --strip-cwd-prefix --exclude .git"

export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'" 

export FZF_ALT_C_COMMAND="fd --path-separator=/ --type=d --hidden --strip-cwd-prefix --exclude .git"
export FZF_ALT_C_OPTS="--preview 'eza --icons --tree | head -200'"

#~ ### Functions

_fzf_compgen_path() {
	  fd --hidden --exclude .git . "$1"
}

# Use fd to generate the list for directory completion
 _fzf_compgen_dir() {
 	  fd --type=d --hidden --exclude .git . "$1"
}



_fzf_comprun() {
 
local command=$1
shift

case "$command" in
cd)           fzf --preview 'eza --icons --tree -a  {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo $'{}"  "$@" ;;
*)            fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}

# Final Execution Commands

eval "$(starship init bash)"

eval "$(zoxide init bash)"

eval "$(fnm env --use-on-cd --shell bash)"

# ---- FZF -----

eval "$(fzf --bash)"

export XDG_CONFIG_HOME=${CYGWIN_HOME_PATH:-HOME}/.config/


# Add this line at the end of .bashrc:
[[ ! ${BLE_VERSION-} ]] || ble-attach

@louiss0
Copy link
Author

louiss0 commented Sep 27, 2024

Blesh is also keeping me from using this kind of command

cd ** 

@akinomyoga
Copy link
Owner

Did you check README of ble.sh? As far as I see your settings, you don't seem to follow the instructions for fzf.

@louiss0
Copy link
Author

louiss0 commented Sep 27, 2024

Did you check README of ble.sh? As far as I see your settings, you don't seem to follow the instructions for fzf.

I did my .blerc file looks like this.

# blerc


ble-import -d integration/fzf-completion
ble-import -d integration/fzf-key-bindings

@louiss0
Copy link
Author

louiss0 commented Sep 27, 2024

Did you check README of ble.sh? As far as I see your settings, you don't seem to follow the instructions for fzf.

I did my .blerc file looks like this.

# blerc


ble-import -d integration/fzf-completion
ble-import -d integration/fzf-key-bindings

I also installed blesh by using basher as my package manager.
Does that have anything to do with it?

How does ble-import determine how files are to be imported?

@akinomyoga
Copy link
Owner

akinomyoga commented Sep 27, 2024

Did you check README of ble.sh? As far as I see your settings, you don't seem to follow the instructions for fzf.

I did my .blerc file looks like this.

# blerc


ble-import -d integration/fzf-completion
ble-import -d integration/fzf-key-bindings

OK, I think I should have written it in README explicitly: as described in the documentation in contrib, you should not have other fzf settings, which will conflict. You have eval "$(fzf --bash)" in your ~/.bashrc, but you need to disable that line when ble.sh is loaded.

However, even if I have an extra eval "$(fzf --bash)" in ~/.bashrc, it would probably work as far as ble-import -d is used. In fact, I tried your .bashrc and .blerc. I cannot reproduce the problem. Instead, I have errors such as fnm: not found and fd: not found, but are they required to reproduce the problem?

I also installed blesh by using basher as my package manager. Does that have anything to do with it?

It shouldn't usually be related, but I'm not sure. I used ble.sh in another location in testing your .bashrc in my environment, but do I need to set up Basher to reproduce the problem in your environment? Did you confirm that the problem only happens with the Basher installation of ble.sh?

Could you minimize your ~/.bashrc and ~/.blerc that reproduce the problem for testing purposes? I'm busy so I don't have time to set up all those Starship, Zoxide, fnm, fd, etc. in your system, and also I doubt that I need to set all these software to reproduce the problem.

@akinomyoga
Copy link
Owner

Now I have a new error when I try to integrate it with fzf.

Also, the situation is unclear. What is that error? Could you provide the error message? Or could you describe what you expect and what you get?

Blesh is also keeping me from using this kind of command

cd ** 

The same for this. Could you describe what you expect and what you get?

@louiss0
Copy link
Author

louiss0 commented Oct 1, 2024

I give up I have no time to spend on this issue. I'm moving on.
Thank you for your help. I will miss multi-line editing.

@louiss0 louiss0 closed this as completed Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants