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

cdk init app: space causes failure #18803

Open
scottiemc7 opened this issue Feb 2, 2022 · 2 comments
Open

cdk init app: space causes failure #18803

scottiemc7 opened this issue Feb 2, 2022 · 2 comments
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1 package/tools Related to AWS CDK Tools or CLI

Comments

@scottiemc7
Copy link

What is the problem?

When running the cdk init app --language csharp command from a directory that has a space in its path, I get the following error:

~\Documents\My Projects\CdkTesting> cdk init app --language csharp

Applying project template app for csharp
Unrecognized command or argument 'Projects\CdkTesting\src\CdkTesting.sln'
Description:
  Add one or more projects to a solution file.

Usage:
  dotnet [options] sln <SLN_FILE> add [<PROJECT_PATH>...]

Arguments:
  <SLN_FILE>      The solution file to operate on. If not specified, the command will search the current directory for
                  one. [default: C:\Users\Scott\Documents\My Projects\CdkTesting\]
  <PROJECT_PATH>  The paths to the projects to add to the solution.

Options:
  --in-root                                Place project in root of the solution, rather than creating a solution
                                           folder.
  -s, --solution-folder <solution-folder>  The destination solution folder path to add the projects to.
  -?, -h, --help                           Show command line help.

Could not add project CdkTesting.csproj to solution CdkTesting.sln. Error code: 1

Reproduction Steps

Run 'cdk init app --language csharp' from a directory with a space in the path

What did you expect to happen?

A project to be created

What actually happened?

Loud noises and explosions

CDK CLI Version

2.10.0 (build e5b301f)

Framework Version

No response

Node.js Version

v12.22.7

OS

Windows

Language

.NET

Language Version

C#

Other information

Moving to a directory without a space in the path solved the issue.

@scottiemc7 scottiemc7 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 2, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Feb 2, 2022
@ryparker ryparker added the p2 label Feb 2, 2022
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1 and removed p2 needs-triage This issue or PR still needs to be triaged. labels Feb 8, 2022
@rix0rrr rix0rrr removed their assignment Feb 8, 2022
bhargav50 added a commit to bhargav50/aws-cdk that referenced this issue Feb 12, 2022
When dotnet command is invoked, if arguments are given
with spaces unescaped, it interprets that as the start
of second command.

In this case, when csharp project is initialized,
`dotnet sln` command is invoked with slnPath and fsprojPath.

Spaces in `slnPath` and `fsprojPath` should be escaped
before providing them as argument to dotnet command

Fixes aws#18803

----

*By submitting this pull request, I confirm that my contribution is made under the terms of t
he Apache-2.0 license*
@bhargav50
Copy link

bhargav50 commented Feb 12, 2022

Hello @ryparker @rix0rrr , I have a question about this PR.
In this specific scenario, the source directory needs to have a space in the name. Shall I create one more integration test for this or a unit test with child_process.spawn function stubbed?

@TheRealAmazonKendra TheRealAmazonKendra self-assigned this May 25, 2022
@ajgoldenwings
Copy link

Thank you @bhargav50 for getting a fix created. I have also ran into this and just removed the spaces from my explorer as a quick fix for the time being.

mergify bot pushed a commit that referenced this issue Jul 8, 2022
A v1 app or library cannot be created from the v2 cli. This cleans up the v1 init template code.

This is stupidly long because of the amount of files deleted and moved so here's a rundown of the changes:
- v1 templates deleted (github is showing some of these as renamed because they were duplicates of the v2 files that did get moved)
- v2 templates removed from `v2` folder and moved directly under `init-templates`
- hook files imports updated (another place where it shows the change to v1 instead of v2 because the contents were the same) for templates and sample apps
- `init.ts`: updated file paths to flattened directory
- `init.test.ts`: 
    - updated tests to only run for v2 templates
    - added test for `fsharp` since it was missing
    - updated .NET tests to look in the contents of the `.sln` file for the project information. I noticed that this test sometimes still passed when the `init` actually failed.


Note: This is the first of two PRs to fix the bug for creating .NET projects with spaces in the file path (issue #18803). This PR was done separately so the bug fix didn't get lost in the 300 file changes due to the cleanup.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TheRealAmazonKendra added a commit that referenced this issue Jul 8, 2022
…space

When running  or  with a space in the path to the project, init will fail. This fix adds in handling for spaces and other special characters in the filepath for both windows systems and posix systems. Tests have been added for posix and manual testing was performed on a windows machine.

Closes issue #18803.
daschaa pushed a commit to daschaa/aws-cdk that referenced this issue Jul 9, 2022
A v1 app or library cannot be created from the v2 cli. This cleans up the v1 init template code.

This is stupidly long because of the amount of files deleted and moved so here's a rundown of the changes:
- v1 templates deleted (github is showing some of these as renamed because they were duplicates of the v2 files that did get moved)
- v2 templates removed from `v2` folder and moved directly under `init-templates`
- hook files imports updated (another place where it shows the change to v1 instead of v2 because the contents were the same) for templates and sample apps
- `init.ts`: updated file paths to flattened directory
- `init.test.ts`: 
    - updated tests to only run for v2 templates
    - added test for `fsharp` since it was missing
    - updated .NET tests to look in the contents of the `.sln` file for the project information. I noticed that this test sometimes still passed when the `init` actually failed.


Note: This is the first of two PRs to fix the bug for creating .NET projects with spaces in the file path (issue aws#18803). This PR was done separately so the bug fix didn't get lost in the 300 file changes due to the cleanup.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TheRealAmazonKendra added a commit that referenced this issue Jul 22, 2022
…space

When running  or  with a space in the path to the project, init will fail. This fix adds in handling for spaces and other special characters in the filepath for both windows systems and posix systems. Tests have been added for posix and manual testing was performed on a windows machine.

Closes issue #18803.
TheRealAmazonKendra added a commit that referenced this issue Sep 3, 2022
…space

When running  or  with a space in the path to the project, init will fail. This fix adds in handling for spaces and other special characters in the filepath for both windows systems and posix systems. Tests have been added for posix and manual testing was performed on a windows machine.

Closes issue #18803.
mergify bot pushed a commit that referenced this issue Sep 9, 2022
…ins space (#21049)

When running `cdk init --language=csharp` or `cdk init --language=fsharp` with one or more spaces in the path to the project, `init` will fail. This fix adds in handling for spaces and other special characters in the file path for both windows systems and posix systems. 

This PR moves the temporary hook directory to the same directory as the source directory so that it can use the local `os.ts` file and other dependencies. `ShellOptions` was also removed because it wasn't used.

Tests have been added for posix and manual testing was performed on a windows machine.

Closes issue #18803.

----

### All Submissions:

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Kruspe pushed a commit to DavidSchwarz2/aws-cdk that referenced this issue Sep 13, 2022
…ins space (aws#21049)

When running `cdk init --language=csharp` or `cdk init --language=fsharp` with one or more spaces in the path to the project, `init` will fail. This fix adds in handling for spaces and other special characters in the file path for both windows systems and posix systems. 

This PR moves the temporary hook directory to the same directory as the source directory so that it can use the local `os.ts` file and other dependencies. `ShellOptions` was also removed because it wasn't used.

Tests have been added for posix and manual testing was performed on a windows machine.

Closes issue aws#18803.

----

### All Submissions:

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants