Giter Club home page Giter Club logo

Comments (4)

MikeMcQuaid avatar MikeMcQuaid commented on June 3, 2024

Cannot reproduce:

mikebook # brew upgrade lilypond-unstable                                                  
==> Downloading https://formulae.brew.sh/api/formula.jws.json
#=#=- #                                                                                              
==> Downloading https://formulae.brew.sh/api/cask.jws.json
#=#=- #                                                                                              
==> Upgrading 1 outdated package:
nwhetsell/lilypond/lilypond-unstable 2.25.13 -> 2.25.14
==> Fetching nwhetsell/lilypond/lilypond-unstable
==> Downloading https://github.com/nwhetsell/homebrew-lilypond/releases/download/lilypond-unstable-2.2
Already downloaded: /opt/workbrew/home/Library/Caches/Homebrew/downloads/a4adb36076d79d01ef065b9c904b0e7085b7557be98daba79c1a35d5fc2aede1--lilypond-unstable-2.25.14.arm64_sonoma.bottle.tar.gz
==> Upgrading nwhetsell/lilypond/lilypond-unstable
  2.25.13 -> 2.25.14 
  • This issue's title and/or description do not reference a single formula e.g. brew install wget.

Please ensure you can reproduce this sort of things with multiple core formulae in future.

from brew.

nwhetsell avatar nwhetsell commented on June 3, 2024

@MikeMcQuaid Thank you for taking a look at this and for all your work on Homebrew.

I’m not sure why this wasn’t reproducible (sorry about that!), but having taken a closer look, the nature of (what seems to be) the issue suggests that it may not be possible to reproduce this with core formulae, because there is no core formula with a sufficiently long name. The fundamental issue appears to be that a string that contains a newline is passed to Tty.truncate, which then truncates the string as if it was too long for a terminal.

It looks like the affected upgrade message is printed here:

oh1 <<~EOS
  Upgrading #{Formatter.identifier(formula.full_specified_name)}
    #{version_upgrade} #{fi_options.to_a.join(" ")}
EOS

oh1 passes its argument to oh1_title here:

def oh1(title, truncate: :auto)
  puts oh1_title(title, truncate:)
end

oh1_title passes the title argument to Tty.truncate here:

title = Tty.truncate(title.to_s) if $stdout.tty? && !verbose && truncate == :auto

In this case, the title being truncated is

Upgrading nwhetsell/lilypond/lilypond-unstable
  2.25.13 -> 2.25.14 

That’s 68 characters (note the space character after the version number on the 2nd line). However, there are 5 more characters after Upgrading for the ANSI escape of green, and an additional 5 characters to restore text color at the end of the first line. With the newline at the end of the string, that brings the total to 79 characters:

Characters
Character indexASCII code (decimal)Character
0 85 U
1 112 p
2 103 g
3 114 r
4 97 a
5 100 d
6 105 i
7 110 n
8 103 g
9 32
10 27 ESC
11 91 [
12 51 3
13 50 2
14 109 m
15 110 n
16 119 w
17 104 h
18 101 e
19 116 t
20 115 s
21 101 e
22 108 l
23 108 l
24 47 /
25 108 l
26 105 i
27 108 l
28 121 y
29 112 p
30 111 o
31 110 n
32 100 d
33 47 /
34 108 l
35 105 i
36 108 l
37 121 y
38 112 p
39 111 o
40 110 n
41 100 d
42 45 -
43 117 u
44 110 n
45 115 s
46 116 t
47 97 a
48 98 b
49 108 l
50 101 e
51 27 ESC
52 91 [
53 51 3
54 57 9
55 109 m
56 10 LF
57 32
58 32
59 50 2
60 46 .
61 50 2
62 53 5
63 46 .
64 49 1
65 51 3
66 32
67 45 -
68 62 >
69 32
70 50 2
71 46 .
72 50 2
73 53 5
74 46 .
75 49 1
76 52 4
77 32
78 10 LF

A common terminal width is 80 characters (the default width in Tty), Tty.truncate truncates strings to have 4 fewer characters than the terminal width, so truncated strings typically have 76 characters. When the affected message is truncated to 76 characters, the last character (at index 75) happens to be the penultimate digit of the new version number, so it appears that the last digit is omitted.

from brew.

MikeMcQuaid avatar MikeMcQuaid commented on June 3, 2024

@nwhetsell We'd review a PR to make the second line of the oh1 a plain old puts instead (the first line should continue to use oh1 and be truncated when necessary.

from brew.

apainintheneck avatar apainintheneck commented on June 3, 2024

That’s 68 characters (note the space character after the version number on the 2nd line). However, there are 5 more characters after Upgrading for the ANSI escape of green, and an additional 5 characters to restore text color at the end of the first line. With the newline at the end of the string, that brings the total to 79 characters:

Ideally we wouldn't count non-printable characters when deciding where to truncate strings but that's not the main issue here.

from brew.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.