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 requires git global configuration #530

Closed
normj opened this issue Aug 8, 2018 · 7 comments · Fixed by #587
Closed

cdk init requires git global configuration #530

normj opened this issue Aug 8, 2018 · 7 comments · Fixed by #587

Comments

@normj
Copy link
Member

normj commented Aug 8, 2018

On my machine I don't have a global git config for username and email because for every repository I create I want to explicitly set whether I'm using my work or personal account. Since I don't have that I get errors when I execute cdk init app --language=typescript

> cdk init app --language=typescript                                                                                                                        
Error: ENOENT: no such file or directory, open 'c:\Users\norm\.aws\config'                                                                                  
    at Object.fs.openSync (fs.js:646:18)                                                                                                                    
    at Object.fs.readFileSync (fs.js:551:33)                                                                                                                
    at Object.readFileSync (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\util.js:97:26)                                  
    at SharedIniFile.loadFile [as ensureFileLoaded] (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\shared_ini.js:19:18)   
    at SharedIniFile.loadProfile [as getProfile] (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\shared_ini.js:52:10)      
    at Config.region (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\node_loader.js:88:34)                                 
    at Config.set (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\config.js:448:39)                                        
    at Config.<anonymous> (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\config.js:283:12)                                
    at Config.each (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\util.js:485:32)                                         
    at new Config (C:\Users\Norm\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\aws-sdk\lib\config.js:282:19)                                        
default@us-west-2 C:\temp\cdk-test\hello-cdk                                                                                                                
> cdk init app --language=typescript                                                                                                                        
Initializing a new git repository...                                                                                                                        
Applying project template app for typescript                                                                                                                
Executing npm install...                                                                                                                                    
npm notice created a lockfile as package-lock.json. You should commit this file.                                                                            
npm WARN hello-cdk@0.1.0 No repository field.                                                                                                               
npm WARN hello-cdk@0.1.0 No license field.                                                                                                                  
                                                                                                                                                            
warning: LF will be replaced by CRLF in .gitignore.                                                                                                         
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in .npmignore.                                                                                                         
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in README.md.                                                                                                          
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in bin/hello-cdk.ts.                                                                                                   
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in cdk.json.                                                                                                           
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in package-lock.json.                                                                                                  
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in package.json.                                                                                                       
The file will have its original line endings in your working directory.                                                                                     
warning: LF will be replaced by CRLF in tsconfig.json.                                                                                                      
The file will have its original line endings in your working directory.                                                                                     
                                                                                                                                                            
*** Please tell me who you are.                                                                                                                             
                                                                                                                                                            
Run                                                                                                                                                         
                                                                                                                                                            
  git config --global user.email "you@example.com"                                                                                                          
  git config --global user.name "Your Name"                                                                                                                 
                                                                                                                                                            
to set your account's default identity.                                                                                                                     
Omit --global to set the identity only in this repository.                                                                                                  
                                                                                                                                                            
fatal: unable to auto-detect email address (got 'Norm@master-control.(none)')                                                                               
git exited with status 128              

Looks like the project isn't finished creating either because when I run cdk synth I get errors about a missing hello-cdk.js.

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 9, 2018

The setup probably finished, but what didn't happen is that the project got compiled for you.

You need to run:

npm run build

first to compile the .ts to .js.

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 9, 2018

Maybe we shouldn't auto-init a git repository.

It feels like an overreach, and might even hinder if you're trying to run cdk init to create a new package in a monorepo (which presumably is already in a git repo).

@RomainMuller, thoughts?

@RomainMuller
Copy link
Contributor

RomainMuller commented Aug 9, 2018

The mono repo story isn't one, because we don't git init if we're already in a git repository.

One first thing we should do is to force the user info for the commit that is auto-created if there isn't any global configuration available, so that git doesn't try to ask...

The other thing is we can allow people to opt out of the git repository by adding a --no-git option, maybe?

The reason I hold dear to that is because a lot of other "package init" tools do this, and I feel it's part of the basic expectations nowadays...

@eladb
Copy link
Contributor

eladb commented Aug 14, 2018

@RomainMuller this is solved by #540, correct?

@RomainMuller
Copy link
Contributor

No. This issue is about it requiring global git configuration.

@eladb eladb changed the title cdk init requires global configuration cdk init requires git global configuration Aug 14, 2018
@eladb
Copy link
Contributor

eladb commented Aug 14, 2018

can you update the description to reflect the actual issue? It starts by talking about the config file issue

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 16, 2018

I think we might also just be able to survive a failing git command and notify the user.

rix0rrr pushed a commit that referenced this issue Aug 16, 2018
Don't stop the 'cdk init' process if there's a problem with 'git
init/add/commit'. Instead, report an error and continue.

This makes sure 'cdk init' doesn't break for people with custom git
setups.

Fixes #530.
rix0rrr added a commit that referenced this issue Aug 17, 2018
Don't stop the 'cdk init' process if there's a problem with 'git
init/add/commit'. Instead, report an error and continue.

This makes sure 'cdk init' doesn't break for people with custom git
setups.

Fixes #530.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants