55*
66*/
77
8- import { info } from "log/mod.ts" ;
8+ import { info , warning } from "log/mod.ts" ;
99import { withSpinner } from "../core/console.ts" ;
1010import { logError } from "../core/log.ts" ;
1111
@@ -20,6 +20,7 @@ import { tinyTexInstallable } from "./impl/tinytex.ts";
2020import { chromiumInstallable } from "./impl/chromium.ts" ;
2121import { downloadWithProgress } from "../core/download.ts" ;
2222import { Confirm } from "cliffy/prompt/mod.ts" ;
23+ import { isWSL } from "../core/platform.ts" ;
2324
2425// The tools that are available to install
2526const kInstallableTools : { [ key : string ] : InstallableTool } = {
@@ -83,59 +84,77 @@ export async function printToolInfo(name: string) {
8384 }
8485}
8586
87+ export function checkToolRequirement ( name : string ) {
88+ if ( name . toLowerCase ( ) === "chromium" && isWSL ( ) ) {
89+ // TODO: Change to a quarto-web url page ?
90+ const troubleshootUrl =
91+ "https://pptr.dev/next/troubleshooting#running-puppeteer-on-wsl-windows-subsystem-for-linux." ;
92+ warning ( [
93+ `${ name } can't be installed fully on WSL with Quarto as system requirements could be missing.` ,
94+ `- Please do a manual installation following recommandations at ${ troubleshootUrl } ` ,
95+ "- See https://github.com/quarto-dev/quarto-cli/issues/1822 for more context." ,
96+ ] . join ( "\n" ) ) ;
97+ return false ;
98+ } else {
99+ return true ;
100+ }
101+ }
102+
86103export async function installTool ( name : string , updatePath ?: boolean ) {
87104 name = name || "" ;
88105 // Run the install
89106 const installableTool = kInstallableTools [ name . toLowerCase ( ) ] ;
90107 if ( installableTool ) {
91- // Create a working directory for the installer to use
92- const workingDir = Deno . makeTempDirSync ( ) ;
93- try {
94- // The context for the installers
95- const context = installContext ( workingDir , updatePath ) ;
108+ if ( checkToolRequirement ( name ) ) {
109+ // Create a working directory for the installer to use
110+ const workingDir = Deno . makeTempDirSync ( ) ;
111+ try {
112+ // The context for the installers
113+ const context = installContext ( workingDir , updatePath ) ;
96114
97- context . info ( `Installing ${ name } ` ) ;
115+ context . info ( `Installing ${ name } ` ) ;
98116
99- // See if it is already installed
100- const alreadyInstalled = await installableTool . installed ( ) ;
101- if ( alreadyInstalled ) {
102- // Already installed, do nothing
103- context . error ( `Install canceled - ${ name } is already installed.` ) ;
104- return Promise . reject ( ) ;
105- } else {
106- // Prereqs for this platform
107- const platformPrereqs = installableTool . prereqs . filter ( ( prereq ) =>
108- prereq . os . includes ( Deno . build . os )
109- ) ;
117+ // See if it is already installed
118+ const alreadyInstalled = await installableTool . installed ( ) ;
119+ if ( alreadyInstalled ) {
120+ // Already installed, do nothing
121+ context . error ( `Install canceled - ${ name } is already installed.` ) ;
122+ return Promise . reject ( ) ;
123+ } else {
124+ // Prereqs for this platform
125+ const platformPrereqs = installableTool . prereqs . filter ( ( prereq ) =>
126+ prereq . os . includes ( Deno . build . os )
127+ ) ;
110128
111- // Check to see whether any prerequisites are satisfied
112- for ( const prereq of platformPrereqs ) {
113- const met = await prereq . check ( context ) ;
114- if ( ! met ) {
115- context . error ( prereq . message ) ;
116- return Promise . reject ( ) ;
129+ // Check to see whether any prerequisites are satisfied
130+ for ( const prereq of platformPrereqs ) {
131+ const met = await prereq . check ( context ) ;
132+ if ( ! met ) {
133+ context . error ( prereq . message ) ;
134+ return Promise . reject ( ) ;
135+ }
117136 }
118- }
119137
120- // Fetch the package information
121- const pkgInfo = await installableTool . preparePackage ( context ) ;
138+ // Fetch the package information
139+ const pkgInfo = await installableTool . preparePackage ( context ) ;
122140
123- // Do the install
124- await installableTool . install ( pkgInfo , context ) ;
141+ // Do the install
142+ await installableTool . install ( pkgInfo , context ) ;
125143
126- // post install
127- const restartRequired = await installableTool . afterInstall ( context ) ;
144+ // post install
145+ const restartRequired = await installableTool . afterInstall ( context ) ;
128146
129- context . info ( "Installation successful" ) ;
130- if ( restartRequired ) {
131- context . info (
132- "To complete this installation, please restart your system." ,
133- ) ;
147+ context . info ( "Installation successful" ) ;
148+ if ( restartRequired ) {
149+ context . info (
150+ "To complete this installation, please restart your system." ,
151+ ) ;
152+ }
134153 }
154+ } finally {
155+ // Cleanup the working directory
156+ Deno . removeSync ( workingDir , { recursive : true } ) ;
135157 }
136- } finally {
137- // Cleanup the working directory
138- Deno . removeSync ( workingDir , { recursive : true } ) ;
139158 }
140159 } else {
141160 // No tool found
0 commit comments