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

Set up Cygwin builds #186

Open
RioNight opened this issue Jan 21, 2024 · 11 comments
Open

Set up Cygwin builds #186

RioNight opened this issue Jan 21, 2024 · 11 comments
Labels
dist Distribution (packaging, binary builds, etc) help wanted Extra attention is needed

Comments

@RioNight
Copy link

RioNight commented Jan 21, 2024

This is the image:
image

I am using the mintty terminal on Windows. I am using bash, which comes with Git for Windows. So, the cat program is from there, which is different than powershell's cat.

scoop install git will install Git for Windows with a terminal called "Git Bash". This is the mintty terminal I am using. See https://mintty.github.io/.

chafa -f sixel image.png produces no output:
image

This is the sixel text file produced by chafa -f sixel image.png > image.six.txt:
image.six.txt

cat-ing this text file displays this image, however:
image

chafa -f iterm image.png produces a large blank screen:
image

This is the iterm text file produced by chafa -f sixel image.png > image.iterm.txt:
image.iterm.txt

cat-ing this text file also works.
image

The ./showimg script in the mintty utils work as expected and display the image correctly with iterm.
https://github.com/mintty/utils

image

According to this, mintty/mintty#1252 (comment) and the other comments in that issue, it seems like it could be solved if chafa is complied with cygwin.

@RioNight
Copy link
Author

RioNight commented Jan 21, 2024

For what it's worth, there is a similar but different problem on Wezterm.
chafa -f sixel image.png will produce no output.
However, cat-ing the sixel text file also does not work, whereas it works in mintty.

chafa -f iterm image.png works, but produces a image in a strange ratio:
image

This ratio is different than when I cat the iterm text file in mintty as aforementioned.

@hpjansson
Copy link
Owner

Great testing! It's especially useful to know that it works with file redirection and not when printed directly to the terminal. We're using WriteConsoleA() on Windows in order to make it work in PowerShell etc. - and it behaves differently when redirected to a file.

We want to use the native runtime, so building with Cygwin is not an option. But we may be able to find a different workaround.

@RioNight
Copy link
Author

From my understanding of the mintty issue, any native Windows app will be limited by the Windows pty, which will consume the special characters needed to display sixel graphics.

That is why you might need cygwin tools at every point to display sixel on Windows. This includes the terminal and the shell.

For example, I used mintty and the cat program from bash (not from pwsh) to output to the terminal.

Wezterm + bash + cat will not work to display these files, which I believe is because Wezterm in not built with cygwin, even though sixel is supposed to supported in Wezterm.
Mintty + pwsh + bash's cat will also not work.

A few notes for completion:

  • To use bash with Wezterm in windows, in the ~/.wezterm.lua config file, set config.default_prog = { 'c:\\users\\USERNAME\\scoop\\apps\\git\\current\\bin\\bash.exe -i -l' }. This is if you installed git with scoop. If you installed it with the default installer you will need to set it to something like this: config.default_prog = { 'c:\\Program Files\\Git\\bin\\bash.exe -i -l' }.
  • You can set config.default_prog = { 'pwsh' } to use pwsh in Wezterm.
  • To use bash's cat in pwsh, you need to add the /usr/bin in the git install folder to the Windows Path. Depending on how you installed git you would add something like C:\Users\USERNAME\scoop\apps\git\current\usr\bin to the PATH. cat may still get called from pwsh, so you need to call bash's cat as cat.exe.
  • To use pwsh in mintty, I just entered pwsh into the bash prompt.

@AnonymouX47
Copy link

AnonymouX47 commented Jan 21, 2024

It's one of the many issues waiting upon microsoft/terminal#1173.

There's nothing chafa can do about it than have a cygwin build. I'll suggest it should be separate from the native windows build, not replace it... i.e treating cygwin as a separate platform.

As for wezterm... unfortunately, I don't think it has cywgin support. So, the only way graphics protocols can work is probably via WSL.

@RioNight
Copy link
Author

RioNight commented Jan 21, 2024

Just wondering, what is the native chafa build used for on Windows, or, what is the drawback of having the defacto Windows build be built by cygwin?

I think Wezterm and mintty (Git Bash) are the two main terminals that can display terminal graphics on Windows.
Sixel won't work on Windows Wezterm because of conpty, so you're left with iterm on Wezterm and mintty and sixel on mintty.

@hpjansson
Copy link
Owner

Just wondering, what is the native chafa build used for on Windows, or, what is the drawback of having the defacto Windows build be built by cygwin?

Interoperability issues, basically. It cuts both ways. In effect, I think @AnonymouX47 is correct. We should be treating Cygwin as an additional platform. This is doable, but every binary distribution I have to do myself adds to release overhead (with the result that I make fewer releases). So I'd be greatly appreciative if someone offered to maintain Cygwin builds.

What's the situation with MSYS2 like? I see they have a fork of Cygwin but also ship mingw-w64 packages, including Chafa. Does their Chafa work on their mintty?

I'm also curious if Chafa behaves correctly when wrapped in winpty.

@AnonymouX47
Copy link

This is doable, but every binary distribution I have to do myself adds to release overhead (with the result that I make fewer releases). So I'd be greatly appreciative if someone offered to maintain Cygwin builds.

True and understandable. I think a title change and a "help wanted" (or so) lablel would be good.

@hpjansson hpjansson added the help wanted Extra attention is needed label Jan 22, 2024
@hpjansson hpjansson changed the title chafa -f sixel and chafa -f iterm do not work in mintty Set up Cygwin builds Jan 22, 2024
@hpjansson hpjansson added the dist Distribution (packaging, binary builds, etc) label Jan 22, 2024
@RioNight
Copy link
Author

RioNight commented Jan 23, 2024

sixel image:
image

iterm image is "empty", just like in the native windows build:
image

My tests were run using the mintty terminal + shell that came with Cygwin.

Without -f sixel, I get a messed up image:
image

gifs somewhat work.
In sixels, they play sped-up, and I need to press ctrl-c to get back the shell prompt.
In iterm, they do not work at all.

I was able to compile chafa with Cygwin straightforwardly.
I think we can use msys2, though I'm not sure. There's also mingw.

I will document my steps here for someone else to reproduce.

  1. Install https://www.cygwin.com/install.html
    Note: See https://www.cygwin.com/faq.html#faq.setup.what-packages. This FAQ and others say that there is no package manager. msys2 has a package manager. https://packages.msys2.org/queue

  2. In the Cygwin installer, you will reach the Select Packages screen. You can re-run the installer to get to this page, so you don't need to select them now.
    image

  3. The packages you need can be found by running chafa's ./autogen.sh. This did not work at first becuase of unix / dos line ending issues. I ran dos2unix on it to fix these. You might need to run it on all the files in the git repository.

  4. ./autogen.sh will tell you the packages you need. Run the cygwin installer again and find them on the package select screen. These are some of the ones I selected (some of these are included on the README.md). For some reason, cygwin here does not show that I selected autoconf.
    image

  5. make / make install said that there was an optional lib avif dependency which I could not find in the cygwin packages. It also said that I had to run ldconfig, which I also could not find.

@RioNight
Copy link
Author

@hpjansson, it might be easy to set up msys builds.
msys builds use a build thing similar to Arch.

https://www.msys2.org/dev/new-package/

image

I am not familiar with creating packages for Arch. Whoever made the chafa Arch package could look at it if it is straightforward.

@hpjansson
Copy link
Owner

I've tagged this with "help wanted" - but with the xz débâcle fresh in mind, I should point out that I won't host binaries built by anyone other than myself on the official site.

I might make an exception for someone who's built trust over time, but I'd want to meet personally to verify their identity and exchange keys.

In the meantime, Chafa is free software, so anyone can build binaries and host them on their own site - but I can't be responsible for them. Hope that makes sense!

@AnonymouX47
Copy link

100% in support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dist Distribution (packaging, binary builds, etc) help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants