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

building on Windows 10 #183

Open
verkaro opened this issue Jun 30, 2023 Discussed in #181 · 8 comments
Open

building on Windows 10 #183

verkaro opened this issue Jun 30, 2023 Discussed in #181 · 8 comments
Labels
enhancement New feature or request help-wanted Help needed to resolve this issue

Comments

@verkaro
Copy link

verkaro commented Jun 30, 2023

Discussed in #181

Originally posted by verkaro June 17, 2023
I am having trouble building Aretext on Windows 10. Is it possible?
I get the errors:
undefined: renameio.NewPendingFile
undefined: renameio.WithPermissions
undefined: renameio.WithExistingPermissions

@wedaly wedaly added the enhancement New feature or request label Jul 1, 2023
@wedaly
Copy link
Contributor

wedaly commented Jul 1, 2023

summarizing the discussion thread:

  • renamio doesn't support Windows by design Remove Windows support google/renameio#20 To build aretext on Windows, we'll need to define a Windows-specific implementation of file.Save() that doesn't use renameio.
  • That should be sufficient to get aretext building on Windows, but there are a few other issues that Windows users will likely run into:
    1. Aretext always inserts "\n" line endings, not the "\r\n" commonly used on Windows. Maybe need a config option to use CR LF line endings.
    2. Aretext handles only UTF-8 encoded files and does not read the byte order mark. We should probably support UTF-16 and the BOM on every platform, but it likely affects Windows users more than Linux/macOS users.
    3. There are a few places where aretext assumes "/" path separators instead of "\" used on Windows. The only one that I think might cause a problem is for the "parent directory" menu command:
      for len(dir) > 0 && dir != "/" && dir != "." {

I'm thinking we use this issue to track "getting aretext to compile on Windows" and then can open separate issues as necessary.

@wedaly wedaly added the help-wanted Help needed to resolve this issue label Jul 1, 2023
@wedaly
Copy link
Contributor

wedaly commented Jul 1, 2023

I started a branch that replaces renamio on Windows: main...windows-build

I've verified that it compiles with GOOS=windows, but haven't tried to run it on Windows yet.

@wedaly
Copy link
Contributor

wedaly commented Jul 1, 2023

It compiles on that branch, but there are a bunch of test failures on Windows:
https://github.com/aretext/aretext/actions/runs/5432166065/jobs/9879034984?pr=185

Looks like mostly path assertions with "/" vs "\" and a panic runtime: VirtualAlloc of 2241159168 bytes failed with errno=1455 likely caused by

for len(dir) > 0 && dir != "/" && dir != "." {
infinite loop'ing.

@verkaro
Copy link
Author

verkaro commented Jul 2, 2023

Hey Will, I saw you edited some code and merged. That's great. I am looking forward to the day when this issue is closed and Aretext on Windows is open. BTW, why did you call this editor Aretext?
Cheers

@wedaly
Copy link
Contributor

wedaly commented Jul 4, 2023

BTW, why did you call this editor Aretext? Cheers

It's inspired by the term "aretê" from ancient greek philosophy (I majored in Philosophy as an undergraduate).

@wedaly
Copy link
Contributor

wedaly commented Jul 4, 2023

opened two related issues for text encoding and line endings on Windows:

@wedaly
Copy link
Contributor

wedaly commented Jul 7, 2023

continuing to experiment on this branch: main...windows-build

a few issues I discovered:

  • Powershell on Windows likes to output the byte-order mark and UTF-16. This is a problem for custom menu items that insert the command output into the document, because the UTF-8 check fails here

    aretext/shellcmd/run.go

    Lines 36 to 38 in 781f23b

    if !utf8.Valid(buf.Bytes()) {
    return "", fmt.Errorf("Shell command output is not valid UTF-8")
    }
  • It's been challenging getting the shellcmd tests to pass on Windows. The commands used in the test (printf, printenv, etc.) aren't available in Powershell, and the equivalent commands behave inconsistently (different text encoding, CRLF line endings). I think this is solvable, but it's tricky to get the test suite working on both Linux and Windows.
  • There's a weird flickering when the terminal redraws. I think this is because we're calling screen.Fill() and on Windows this causes tcell to clear the screen. I'm not sure if this is a bug in tcell on Windows (the Linux terminal implementation doesn't behave this way) or if there's a better way to redraw the screen that I'm not aware of.

However, I can confim that the windows-build branch compiles, runs, and mostly works on Windows 11, which is kind of neat. I cherry-picked a few commits from that branch to main (a90fb55 b3250b4 and cc12ff7) because they're easy fixes that aren't Windows-specific.

I'm going to stop working on this now, but open to contributions if anyone wants to pick this up.

@wedaly
Copy link
Contributor

wedaly commented Feb 12, 2024

Windows flickering may have been fixed in the latest tcell release: gdamore/tcell#647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help-wanted Help needed to resolve this issue
Projects
None yet
Development

No branches or pull requests

2 participants