cli icon indicating copy to clipboard operation
cli copied to clipboard

init command with `-p` fails if file (or directory) with same name as the starter kit already exists in current directory

Open harmony7 opened this issue 1 year ago • 0 comments

Version

Fastly CLI version v10.12.3 (f0fe32f4)
Built with go version go1.22.4 linux/amd64 (2024-07-28)
Viceroy version: viceroy 0.10.2

What happened

% cd ./my-app
% fastly compute init -p ./my-app
Creating a new Compute project.

Press ^C at any time to quit.

  ... (skipping lines of output) ...

Starter kit:
[1] Default starter for JavaScript
    A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules.
    https://github.com/fastly/compute-starter-kit-javascript-default
[2] Empty starter for JavaScript
    An empty application template for the Fastly Compute environment which returns a 200 OK response.
    https://github.com/fastly/compute-starter-kit-javascript-empty
[3] Default starter for TypeScript
    A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules.
    https://github.com/fastly/compute-starter-kit-typescript

INFO: For a complete list of Starter Kits:
    https://www.fastly.com/documentation/solutions/starters

Choose option or paste git URL: [1] 1

✗ Fetching package template

ERROR: failed to create local compute-starter-kit-javascript-default archive: open compute-starter-kit-javascript-default: is a directory.

If you believe this error is the result of a bug, please file an issue: https://github.com/fastly/cli/issues/new?labels=bug&template=bug_report.md
%

This occurs when a directory called compute-starter-kit-javascript-default already exists in the current directory.

The problem seems to arise from https://github.com/fastly/cli/blob/ad4b939e13d877410b1d8fd49f1abbd2279a8840/pkg/commands/compute/init.go#L947-L955 where the file is created in the current directory, rather than using something like os.TempDir().

My current workaround is to forego the -p argument and switch to my-app directory first before running the command.

harmony7 avatar Jul 28 '24 08:07 harmony7