%M2% not working in system variable Path but in user variable Path only

后端 未结 1 671
梦谈多话
梦谈多话 2020-12-18 13:25

I am installing Maven and need to set M2 and M2_Home. I have set them in the user variables in Environment variables. And I added ;%M2% to the Path variable in

相关标签:
1条回答
  • 2020-12-18 14:07

    You'd have to look at the Windows source code to be certain what's going on, but this doesn't surprise me. Based on my testing, it appears that system environment variables can only reference other system environment variables, not user environment variables.

    Note that echo %PATH% should show the expanded path. You shouldn't see %M2%.

    This is probably because system environment variables sometimes need to be expanded in situations where there is no user context. If user environment variables were included in the expansion of system environment variables this would need to be treated as a special case. It's also possible that this was considered the preferred behaviour so that a user's environment variables couldn't unexpectedly affect the interpretation of system variables, or that there are issues related to the way environment variables are inherited between processes.

    Either add %M2% to the user path as you've done, or make M2 a system rather than a user environment variable.

    0 讨论(0)
提交回复
热议问题