vscode-docker icon indicating copy to clipboard operation
vscode-docker copied to clipboard

Path Argument Error When Adding Flutter Support to VS Code Docker Extension

Open hs-dev1 opened this issue 1 year ago • 4 comments

I've been working on adding support for Flutter projects in the ms-azuretools.vscode-docker extension. This involves generating Dockerfiles for Flutter projects. However, I've encountered an error related to the path argument being undefined. The specific error message is: "Error: The 'path' argument must be of type string. Received undefined."

I am trying to add the path when generating the Dockerfile into the project for Flutter, but it's not working and throws the error mentioned above.

Here is the function where I add the path when generating the Dockerfile. If you need the code, please let me know. ` private async getInputPath(wizardContext: TWizardContext): Promise { const config = vscode.workspace.getConfiguration('docker'); const settingsTemplatesPath = config.get<string | undefined>('scaffolding.templatePath', undefined); const defaultTemplatesPath = path.join(ext.context.asAbsolutePath('resources'), 'templates');

    console.log('Workspace Folder:', wizardContext.workspaceFolder);
    console.log('Dockerfile Directory:', wizardContext.dockerfileDirectory);
    ///TODO: for flutter [dockerfileDirectory] is undefined need to check that

    let subPath: string;
    switch (wizardContext.platform) {
        case 'Node.js':
            subPath = path.join('node', `${this.fileType}.template`);
            break;
        case 'Flutter':
            subPath = path.join('flutter', `${this.fileType}.template`);
            break;
        case 'Python: General':
            subPath = path.join('python', `${this.fileType}.template`);
            break;
        // Additional cases...
        default:
            throw new Error(`Unknown platform '${wizardContext.platform}'`);
    }

    // Validate paths before usage
    console.log('Settings Templates Path:', settingsTemplatesPath);
    console.log('Default Templates Path:', defaultTemplatesPath);
    console.log('SubPath:', subPath);

    if (!settingsTemplatesPath && !defaultTemplatesPath) {
        throw new Error('Both settingsTemplatesPath and defaultTemplatesPath are undefined.');
    }

    // Use valid paths
    return (settingsTemplatesPath && await this.scanUpwardForFile(path.join(settingsTemplatesPath, subPath))) ||
        await this.scanUpwardForFile(path.join(defaultTemplatesPath, subPath));
}

`

but if I select any other option it generates Dockerfile normally.

hs-dev1 avatar Aug 04 '24 17:08 hs-dev1

Kindly assist on this @bwateratmsft , @chrisdias , @StephenWeatherford , @ravipal

hussnain-2015371 avatar Aug 05 '24 06:08 hussnain-2015371

@hussnain-2015371 , can you share the error message or call stack of where you hit this. Or please share out a branch or repo for your code. In a simple test I was able to make this work

dbreshears avatar Aug 07 '24 18:08 dbreshears

@hussnain-2015371 , can you share the error message or call stack of where you hit this. Or please share out a branch or repo for your code. In a simple test I was able to make this work

here's branch: https://github.com/hs-dev1/vscode-docker/tree/vscode-docker-flutter

hs-dev1 avatar Aug 08 '24 17:08 hs-dev1

@hussnain-2015371, after line 18 in https://github.com/hs-dev1/vscode-docker/blob/vscode-docker-flutter/src/scaffolding/wizard/flutter/FlutterGatherInformationStep.ts you need to call

await super.prompt(wizardContext);

the base GatherInformationStep sets the wizardContext.dockerfileDirectory

dbreshears avatar Aug 15 '24 20:08 dbreshears

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

AzCode-Bot avatar Sep 04 '24 05:09 AzCode-Bot