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

Can't use Bootstrap 5 behind proxy #2753

Closed
AlbertRapp opened this issue Aug 14, 2024 · 9 comments
Closed

Can't use Bootstrap 5 behind proxy #2753

AlbertRapp opened this issue Aug 14, 2024 · 9 comments
Labels
front end 🌷 General HTML, CSS, and JS issues

Comments

@AlbertRapp
Copy link

Hi there 👋

Unfortunately, setting

template:
  bootstrap: 5

in my _pkgdown.yml file doesn't work for me and I get the following error:

Copying <pkgdown>/BS5/assets/pkgdown.js to pkgdown.js
Error in utils::download.file(file$url, cache_path, quiet = TRUE, mode = "wb") : 
  cannot open URL 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js'
In addition: Warning message:
In utils::download.file(file$url, cache_path, quiet = TRUE, mode = "wb") :
  URL 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js': status was 'Couldn't resolve host name'

I'm assuming this happens because I am behind a proxy and pkgdown seems to not be able to fetch the files for headroom.js. The interesting thing is that copying the files before that like <pkgdown>/BS5/assets/lightswitch.js works and for Bootstrap 3 I also don't get any issue (even though in the resulting docs headroom.js is still included via a <script> tag). Also it's worth noting that I've already tried setting options(pkgdown.internet = FALSE) but this didn't have any effect.

@jayhesselberth
Copy link
Collaborator

Yes, the BS5 configuration will require an outside line to download external dependencies.

Some of the JS / CSS is included in the package (lightswitch.js) and is just copied from disk.

BS3 doesn't use the new dependency resolution approach, so you also won't need a connection.

I guess this might be an argument to keep the BS3 approach around.

@jayhesselberth
Copy link
Collaborator

We might also throw a more informative error early a package is using BS5 but there is no internet connection.

@AlbertRapp
Copy link
Author

Yes, the BS5 configuration will require an outside line to download external dependencies.

Why though? The Bootstrap 3 version can (at least for headroom.min.js) also use the JS scripts by including them via a <script> tag and linking to the JS file on a CDN. That's why Bootstrap 3 can be used to build the pkgdown website. Of course, this requires an internet connection to properly load the pkgdown page in the browser. But for building the page, that's not necessary. Is it possible to make that possible for BS5 as well?

@maelle
Copy link
Collaborator

maelle commented Aug 14, 2024

👋 @AlbertRapp here's the change that was made: now external assets are downloaded at build time #2249

@AlbertRapp
Copy link
Author

Hi @maelle 👋 Thanks for the tip. This part explains the reasoning perfectly for me:

Direct asset inclusion might be relevant to people trying to strictly adhere to privacy regulations like GDPR, since otherwise IP addresses of site visitors are sent to the asset CDN operators (based in the US) on page load.

Now, I'm kind of at a conundrum though. I can set a proxy to download external assets but then the git commands that are part of the building processes don't work anymore. I'm guessing that happens due to pushes to an internal repo. Any chance it's possible to provide the external assets via the pkgdown/ directory? 🤔

@camillemndn
Copy link

Hi, i do not know if that is relevant to your issue, but since #2249 I have a similar error message when trying to build a site without an internet connection, even though options(pkgdown.internet = FALSE) was set.

Would there be an option to cache the external dependencies beforehand if options(pkgdown.internet = FALSE) is set? Thank you!

@jayhesselberth jayhesselberth added the front end 🌷 General HTML, CSS, and JS issues label Nov 29, 2024
@matthiasgomolka
Copy link

I have the same issue. Building the site with BS 3 works fine, but I would like to use BS 5. It would be great if all templates would work without an internet connection (especially since there is this explicit option).

@jayhesselberth
Copy link
Collaborator

jayhesselberth commented Jan 16, 2025

Pleasee see #2829 (comment). You only need an internet connection once to init_site() and cache dependencies. After that, the site should build offline.

We should address the pkgdown.internet option, I don't remember why we had it and seems like it's either not working as intended or we need to clarify why / when you should use it.

@matthiasgomolka
Copy link

@jayhesselberth, thanks for the information. Unfortunately, this does not help because I never have an internet connection from my R Session at work.

The only thing helping me would be a completely self-contained package, which I would be able to install from a local repository after a security scan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front end 🌷 General HTML, CSS, and JS issues
Projects
None yet
Development

No branches or pull requests

5 participants