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

Cannot apply a change to a different path. #3169

Closed
dumyjob opened this issue Nov 17, 2016 · 9 comments · Fixed by #3802
Closed

Cannot apply a change to a different path. #3169

dumyjob opened this issue Nov 17, 2016 · 9 comments · Fixed by #3802
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix

Comments

@dumyjob
Copy link

dumyjob commented Nov 17, 2016

admin@user MINGW64 /e/git/ng2-adminlte/src/app/logon (master)
$ ng g component ./sign-in
installing component
create src\app\sign-in\sign-in.component.css
create src\app\sign-in\sign-in.component.html
create src\app\sign-in\sign-in.component.spec.ts
create src\app\sign-in\sign-in.component.ts
Cannot apply a change to a different path.
Error: Cannot apply a change to a different path.
at MultiChange.appendChange (E:\git\ng2-adminlte\node_modules@angular-cli\ast-tools\src\change.js:45:19)
at E:\git\ng2-adminlte\node_modules@angular-cli\ast-tools\src\change.js:36:86
at Array.forEach (native)
at new MultiChange (E:\git\ng2-adminlte\node_modules@angular-cli\ast-tools\src\change.js:36:45)
at E:\git\ng2-adminlte\node_modules@angular-cli\ast-tools\src\ast-utils.js:222:16
at tryCatch (E:\git\ng2-adminlte\node_modules\es6-promise\dist\lib\es6-promise-internal.js:195:12)
at invokeCallback (E:\git\ng2-adminlte\node_modules\es6-promise\dist\lib\es6-promise-internal.js:210:13)
at publish (E:\git\ng2-adminlte\node_modules\es6-promise\dist\lib\es6-promise-internal.js:178:7)
at flush (E:\git\ng2-adminlte\node_modules\es6-promise\dist\lib\es6-promise\asap.js:94:5)
at doNTCallback0 (node.js:428:9)
at process._tickCallback (node.js:357:13)

ng version:
$ ng --version
angular-cli: 1.0.0-beta.19-3
node: 5.0.0
os: win32 ia32

@Meligy
Copy link
Contributor

Meligy commented Nov 17, 2016

Does the same problem happen with just normal Windows command prompt?

The path you give to the generate command is usually relative to src/app without you having to indicate it by using ./ or anything. I'm not sure if the ./ scenario is supported at all, but it still shouldn't fail the way you describe.

Please try with normal command prompt to rule away the possibility of MINGW64 doing anything funky.

Thanks.

Cheers,

@dumyjob
Copy link
Author

dumyjob commented Nov 17, 2016

ng g component ./sign-in,it's work on Windows command,failed on git bash.
thanks for your help!

@Meligy
Copy link
Contributor

Meligy commented Nov 17, 2016

Oh. This is going to be a tough nut to crack.

My guess is that Git Bash is messing with your input, maybe replacing / with \, and maybe also sending absolute path (both cases are unusual, but not sure if they fail).

If this is the case, can I ask you to try and wrap the path in single quotes'? Like:

ng g component './sign-in'

If this fails, then try in Windows command line changing / to \, and if this fail, I'm guessing there'll be a bug for that (whether there is or not, that would be the underlying bug if this is the case).

It might be fixed in latest version already, beta.20-4, but I wouldn't recommend upgrading and testing until #3158 is resolved.

@dumyjob
Copy link
Author

dumyjob commented Nov 18, 2016

At git Bash,

ng g component './dash'

it works,but it generate component at app directory.

the result:
admin@user MINGW64 /e/git/ng2-admin-lite/src/app/dashboard (master)
$ ng g component './dash'
installing component
create src\app\dash\dash.component.css
create src\app\dash\dash.component.html
create src\app\dash\dash.component.spec.ts
create src\app\dash\dash.component.ts

At Windows command,I change / to \ . the generate result is same as original.

the result:
E:\git\ng2-admin-lite\src\app\dashboard>ng g component .\dash
installing component
create src\app\dashboard\dash\dash.component.css
create src\app\dashboard\dash\dash.component.html
create src\app\dashboard\dash\dash.component.spec.ts
create src\app\dashboard\dash\dash.component.ts

@afgane
Copy link

afgane commented Dec 1, 2016

I seem to be seeing the same error with the latest release:

$ ng --version
angular-cli: 1.0.0-beta.20-4
node: 6.9.1
os: darwin x64
$ ng g module logout
installing module
  create src/app/logout/logout.module.ts
installing component
  create src/app/logout/logout.component.css
  create src/app/logout/logout.component.html
  create src/app/logout/logout.component.spec.ts
  create src/app/logout/logout.component.ts
Cannot apply a change to a different path.
Error: Cannot apply a change to a different path.
    at MultiChange.appendChange (/Users/eafgan/projects/pprojects/launcher/ui/node_modules/@angular-cli/ast-tools/src/change.js:45:19)
    at /Users/eafgan/projects/pprojects/launcher/ui/node_modules/@angular-cli/ast-tools/src/change.js:36:86
    at Array.forEach (native)
    at new MultiChange (/Users/eafgan/projects/pprojects/launcher/ui/node_modules/@angular-cli/ast-tools/src/change.js:36:45)
    at /Users/eafgan/projects/pprojects/launcher/ui/node_modules/@angular-cli/ast-tools/src/ast-utils.js:222:16
    at process._tickCallback (internal/process/next_tick.js:103:7)

@Meligy
Copy link
Contributor

Meligy commented Dec 2, 2016

This output shows beta 20-4. There has been beta 21 for a while and beta 22 should have been available on npm any minute.

@afgane
Copy link

afgane commented Dec 2, 2016

Sill seeing the same error with beta 21.

@rapPayne
Copy link

I experienced the same error after creating a component, deleting that same component via 'rm -r' and then re-creating it. The cause for me was that I didn't remove the reference from app.module.ts. Once I deleted it manually from app.module.ts, ng g myComponent throws no errors. @Meligy, maybe that will give you a clue as to the real source?

@filipesilva filipesilva added command: generate P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix labels Dec 29, 2016
Brocco added a commit to Brocco/angular-cli that referenced this issue Dec 31, 2016
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this issue Feb 9, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants