r-lib / ragg

Graphic Devices Based on AGG
https://ragg.r-lib.org
Other
172 stars 24 forks source link

C++ error during installation with freetype2 2.13.3 #170

Closed ChangqingW closed 3 days ago

ChangqingW commented 4 weeks ago

Encountered the following error during installation:

agg/src/agg_font_freetype.cpp: In instantiation of ‘bool agg::decompose_ft_outline(const FT_Outline&, bool, const trans_affine&, PathStorage&) [with PathStorage = path_storage_integer<int, 6>; FT_Outline = FT_Outline_]’:
agg/src/agg_font_freetype.cpp:1071:48:   required from here
 1071 |                         if(decompose_ft_outline(m_cur_face->glyph->outline,
      |                            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1072 |                                                 m_flip_y,
      |                                                 ~~~~~~~~~
 1073 |                                                 m_affine,
      |                                                 ~~~~~~~~~
 1074 |                                                 m_path32))
      |                                                 ~~~~~~~~~
agg/src/agg_font_freetype.cpp:182:35: error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]
  182 |             tags  = outline.tags  + first;
      |                     ~~~~~~~~~~~~~~^~~~~~~
      |                                   |
      |                                   unsigned char*
agg/src/agg_font_freetype.cpp: In instantiation of ‘bool agg::decompose_ft_outline(const FT_Outline&, bool, const trans_affine&, PathStorage&) [with PathStorage = path_storage_integer<short int, 6>; FT_Outline = FT_Outline_]’:
agg/src/agg_font_freetype.cpp:1092:48:   required from here
 1092 |                         if(decompose_ft_outline(m_cur_face->glyph->outline,
      |                            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1093 |                                                 m_flip_y,
      |                                                 ~~~~~~~~~
 1094 |                                                 m_affine,
      |                                                 ~~~~~~~~~
 1095 |                                                 m_path16))
      |                                                 ~~~~~~~~~
agg/src/agg_font_freetype.cpp:182:35: error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]
  182 |             tags  = outline.tags  + first;
      |                     ~~~~~~~~~~~~~~^~~~~~~
      |                                   |
      |                                   unsigned char*
make: *** [/usr/lib64/R/etc/Makeconf:204: agg/src/agg_font_freetype.o] Error 1
ERROR: compilation failed for package ‘ragg’
* removing ‘/home/q/R/x86_64-pc-linux-gnu-library/4.4/ragg’

The downloaded source packages are in
        ‘/tmp/RtmpUzUHT4/downloaded_packages’
Warning message:
In install.packages("ragg") :
  installation of package ‘ragg’ had non-zero exit status
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.12.0
LAPACK: /usr/lib/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Australia/Melbourne
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.4.1 tools_4.4.1

I believe I had all the required libraries installed:

> pacman -Q | grep -P '(freetype2)|(libpng)|(libtiff)|(libjpeg)'
freetype2 2.13.3-1
libjpeg-turbo 3.0.3-1
libpng 1.6.43-1
libtiff 4.6.0-5
ChangqingW commented 4 weeks ago

Looks like with the newer version of freetype2, tags from FT_Outline changed from char* to unsigned char*, I wonder if this is causing the error. https://sourceforge.net/projects/freetype/files/freetype2/2.13.3/

CHANGES BETWEEN 2.13.2 and 2.13.3 (2024-Aug-11)

  I. IMPORTANT CHANGES

  - Some  fields  in  the  `FT_Outline` structure  have been   changed
    from signed  to unsigned type,  which  better reflects  the actual
    usage.   It  is  also  an  additional  means  to  protect  against
    malformed input.

https://freetype.org/freetype2/docs/reference/ft2-outline_processing.html#ft_outline https://freetype.sourceforge.net/freetype2/docs/reference/ft2-outline_processing.html#FT_Outline

ChangqingW commented 4 weeks ago

https://github.com/r-lib/ragg/blob/0bd90a88054f902937dc5be907e884886cb86457/src/agg/src/agg_font_freetype.cpp#L182

-            tags  = outline.tags  + first;
+            tags  = (char*)outline.tags  + first;

Casting outline.tags to char* seems to have resolved this for me.

joshweiland commented 2 weeks ago

Until/unless freetype2 is updated, is there a way to get around this error in R? This is blocking installation of tidyverse as well. I'm not a C++ user, but I can code - do I have to learn to hack into freetype2? Is there a way to modify the ragg installation to get around this? Sorry if this is not an appropriate question. Also, does anyone know an order of magnitude timeline for something like this to be updated in a downstream code like freetype2? Days, weeks, months? Thanks!

emersonhsieh commented 2 weeks ago

Until/unless freetype2 is updated, is there a way to get around this error in R? This is blocking installation of tidyverse as well. I'm not a C++ user, but I can code - do I have to learn to hack into freetype2? Is there a way to modify the ragg installation to get around this? Sorry if this is not an appropriate question. Also, does anyone know an order of magnitude timeline for something like this to be updated in a downstream code like freetype2? Days, weeks, months? Thanks!

Freetype was updated to 2.13.3 at commit https://github.com/Homebrew/homebrew-core/commit/28e294c4d21da7d03e441d569d07c38365d2d74e. Its immediate parent is https://github.com/Homebrew/homebrew-core/commit/d28afc3bfdb5d24eab02157bfffcc9e17ed6666c, which contains the script to install freetype version 2.13.2.

To install freetype version 2.13.2, download the previous installation script and manually install with brew:

curl -L https://raw.githubusercontent.com/Homebrew/homebrew-core/d28afc3bfdb5d24eab02157bfffcc9e17ed6666c/Formula/f/freetype.rb > freetype.rb && brew install freetype.rb

Then install.packages("ragg") should work.

joshweiland commented 1 week ago

Thanks for the tip. I have run the code for Freetype as above, and it seems to work - it says that 2.13.2 is installed. I still get the same error when trying to install ragg, however. When I run freetype-config --version, it says 26.2.20, which the internet says is 2.13.3. So though it looks like 2.13.2 is being installed, it seems it is not? Thank you for all the help!

dimino commented 1 week ago

Based on email correspondence, @thomasp85 doesn't consider this to be worth fixing for the time being, since there are workarounds available to sufficiently sophisticated R users.

thomasp85 commented 1 week ago

@dimino i would be grateful if you did not misrepresent what I wrote. It is definitely worth fixing, but I am having higher priorities right now. I provided you with workarounds for the time being to help you out, not to say that the issue doesn't matter

dimino commented 1 week ago

@thomasp85 apologies if there was confusion! My intention was to explain that you didn't consider this worth fixing for the time being, which is what "higher priorities" means. Worth here being applied relatively to the worth of the other work you're doing.

And strictly speaking no, you provided no workarounds to me I was not already aware of. I submitted the PR based on a workaround provided by @ChangqingW .

Further, the issue is not my specific problem, but the problem of all remaining people for whom you have not provided a sufficient workaround for, which are the people who may lack the technical sophistication to apply the workarounds discussed here.

This is obviously your call, as you have refused my offer to help merge the relevant PR and cut a release. You can decide how to prioritize your time and manage this repo however you like. But the fact remains that you consider this blocking issue (to others, not me) to be of insufficient worth to resolve in a timely manner. That is a fact worth making clear to anyone who comes here searching for a solution.

fvalenduc commented 1 week ago

It would be more interesting if you could share the workarounds here. Personally, I cloned the original repo, I applied the patch quoted above and I installed the package from this repo.

thomasp85 commented 1 week ago

For the time being, the PR can easily be installed with pak::pak("r-lib/ragg#171")

Be aware that I haven't looked at the changes in the PR so I can't really vouch for it's correctness, but if it works it can get you through the next couple of weeks

ablechow29 commented 1 week ago

I am experiencing the same issue described by the OP. I am on archlinux and can confirm that re-installing freetype2 does not resolve the issue. And pak::pak("r-lib/ragg#171") does not install ragg successfully either.

Downgrading freetype2 to is previous version does resolve the issue sudo pacman -U file:///var/cache/pacman/pkg/freetype2-2.13.2-2-x86_64.pkg.tar.zst install.packages("ragg") works normally afterwords Hopefully this gets fixed soon.

chartgerink commented 1 week ago

@dimino no reason to be pedantic to the maintainer. It's not a good look. You are not entitled to their time, attention, or having your suggestions included.

Thanks for all your work on this open source package @thomasp85 <3

dimino commented 1 week ago

@chartgerink I hope I haven't upset you! I feel zero entitlement to anyone's time or attention, but when a maintainer refuses to accept the offered help, they're deliberately creating a bottleneck around their availability. This is any maintainer's prerogative, of course, but the bottleneck remains, as do those who are stuck waiting behind it.

joshweiland commented 5 days ago

I've been able to get ragg (and therefore tidyverse) installed using pak::pak("r-lib/ragg#171"). Thanks to all who are working on this!

vippeople22 commented 4 days ago

https://archive.archlinux.org/packages/f/freetype2/ 2.13.2-2 works fine after using sudo pacman -U file.tar.gz and install.packages("tidyverse") in RStudio

WildPenquin commented 3 days ago

On Arch here, I don't need to downgrade libfreetype2.2.13.3-1 works fine with the PR (pak::pak("r-lib/ragg#171").

Thanks for the work and all involved!

EDIT: I don't know why other users here need to downgrade libfreetype2. I'm guessing you are running install.packages("ragg") afterwards? Note, you don't need (and absolutely don't want to do that as it will undo the ragg installation with the PR) to do that, as pak has already installed ragg. As you have installed pak, it's much more worthwhile to use it for installing packages now.