neolee / pilot

进入编程世界的第一课
584 stars 840 forks source link

git 提交出现报错,什么原因,怎么处理 #150

Closed gongzhigao closed 4 years ago

gongzhigao commented 4 years ago

PS C:\Users\龚志高\code\learn-git> git status On branch master

No commits yet

Changes to be committed: (use "git rm --cached ..." to unstage) new file: README.md

PS C:\Users\龚志高\code\learn-git> git commit hint: Waiting for your editor to close the file... internal/modules/cjs/loader.js:586 throw err; ^

Error: Cannot find module 'C:\Users' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:584:15) at Function.Module._load (internal/modules/cjs/loader.js:510:25) at Function.Module.runMain (internal/modules/cjs/loader.js:746:12) at startup (internal/bootstrap/node.js:282:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:759:3) error: There was a problem with the editor 'code -w'. Please supply the message using either -m or -F option. PS C:\Users\龚志高\code\learn-git>

neolee commented 4 years ago

好像你的 Visual Studio Code 有点问题,你在开始菜单找到 Visual Studio Code 运行下看看有没有问题,然后在命令行直接运行 code 试试?

gongzhigao commented 4 years ago

从开始菜单运行Visual Studia Code没有问题,命令行直接运行code也没有问题

neolee commented 4 years ago

运行 git config --list 给我看看。

gongzhigao commented 4 years ago

PS C:\Users\龚志高\code\learn-git> git config --list core.symlinks=false core.autocrlf=true color.diff=auto color.status=auto color.branch=auto color.interactive=true help.format=html http.sslcainfo=/ssl/certs/ca-bundle.crt diff.astextplain.textconv=astextplain rebase.autosquash=true filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge --skip -- %f filter.lfs.process=git-lfs filter-process --skip filter.lfs.required=true credential.helper=helper-selector credential.helper=manager user.name=Zhigao Gong user.email=zhigao.gong@gmail.com core.editor=code -w core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true core.symlinks=false core.ignorecase=true PS C:\Users\龚志高\code\learn-git>

neolee commented 4 years ago

那你在命令行运行 code -w 呢?

gongzhigao commented 4 years ago

运行了Visual Studia Code

neolee commented 4 years ago

此时命令行窗口里啥状态?

gongzhigao commented 4 years ago

在左端出现亮标,没有任何显示

gongzhigao commented 4 years ago

关闭Visual Studia Code后,出现 PS C:\Users\龚志高\code\learn-git>

neolee commented 4 years ago

感觉一切正常,你再试试 git commit

gongzhigao commented 4 years ago

image

neolee commented 4 years ago

你执行 scoop checkup 有什么反馈?

gongzhigao commented 4 years ago

PS C:\Users\龚志高\code\learn-git> scoop checkup WARN Windows Defender may slow down or disrupt installs with realtime scanning. Consider running: sudo Add-MpPreference -ExclusionPath 'C:\Users\龚志高\scoop' (Requires 'sudo' command. Run 'scoop install sudo' if you don't have it.) WARN Windows Defender may slow down or disrupt installs with realtime scanning. Consider running: sudo Add-MpPreference -ExclusionPath 'C:\ProgramData\scoop' (Requires 'sudo' command. Run 'scoop install sudo' if you don't have it.) WARN LongPaths support is not enabled. You can enable it with running: Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 ERROR 'Inno Setup Unpacker' is not installed! It's required for unpacking InnoSetup files. Please run 'scoop install innounp'. ERROR 'dark' is not installed! It's required for unpacking installers created with the WiX Toolset. Please run 'scoop install dark' or 'scoop install wixtoolset'. WARN Found 5 potential problems. PS C:\Users\龚志高\code\learn-git>

neolee commented 4 years ago

有五个配置相关的建议,最好一一照做,方法是依次执行:

scoop install sudo
sudo Add-MpPreference -ExclusionPath 'C:\Users\龚志高\scoop'
sudo Add-MpPreference -ExclusionPath 'C:\ProgramData\scoop'
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
scoop install innounp dark
neolee commented 4 years ago

这些都无问题的话,再试试 git commit 看看。

gongzhigao commented 4 years ago

PS C:\Users\龚志高> scoop install sudo Updating Scoop... Updating 'main' bucket...

neolee commented 4 years ago

换个时间试试,看上去网络不太稳定。

gongzhigao commented 4 years ago

PS C:\Users\龚志高> scoop uninstall sudo Uninstalling 'sudo' (). 'sudo' was uninstalled. PS C:\Users\龚志高> scoop install sudo Installing 'sudo' (0.2018.07.25) [64bit] sudo.ps1 (2.0 KB) [==================================================================================================================================] 100% Checking hash of sudo.ps1 ... ok. Linking ~\scoop\apps\sudo\current => ~\scoop\apps\sudo\0.2018.07.25 Creating shim for 'sudo'. 'sudo' (0.2018.07.25) was installed successfully! PS C:\Users\龚志高> sudo Add-MpPreference -ExclusionPath 'C:\Users\龚志高\scoop' PS C:\Users\龚志高> sudo Add-MpPreference -ExclusionPath 'C:\ProgramData\scoop' PS C:\Users\龚志高> Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 Set-ItemProperty : 不允许所请求的注册表访问权。 所在位置 行:1 字符: 1

gongzhigao commented 4 years ago

image

neolee commented 4 years ago

试试开一个 {{ PowerShell (Admin) }} 命令行窗口,然后执行 Set-ItemProperty 那行命令。

或者在那行命令前加上 sudo 也可以。

gongzhigao commented 4 years ago

scoop install sudo sudo Add-MpPreference -ExclusionPath 'C:\Users\龚志高\scoop' sudo Add-MpPreference -ExclusionPath 'C:\ProgramData\scoop' Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 scoop install innounp dark 这些依次执行完后,git commit 还是报错

gongzhigao commented 4 years ago

image

gongzhigao commented 4 years ago

image

neolee commented 4 years ago

你这个问题已经排除了很多常见根源,进入比较少见的情况了……

你运行 git commit 的时候,Visual Studio Code 会打开吗?还是直接出错呢?如果可以打开 Code,请你截个屏,同时包含命令行窗口和 Visual Studio Code 窗口。

gongzhigao commented 4 years ago

运行git commit的时候,没有打开Code直接出错

XueAE commented 4 years ago

遇到相同问题,报错内容有所不同,但给出的解决方案都是 配置一样的五样东西。 运行第一段代码“scoop install sudo”时,出现报错,如下:“无法连接到远程服务器 URL https://raw.githubusercontent.com/lukesampson/psutils/3290c04d7653ea8183a5e11d3d5a4e46716035d1/sudo.ps1 is not valid” 反复几此安装和卸载后,情况还是一样。

gongzhigao commented 4 years ago

遇到相同问题,报错内容有所不同,但给出的解决方案都是 配置一样的五样东西。 运行第一段代码“scoop install sudo”时,出现报错,如下:“无法连接到远程服务器 URL https://raw.githubusercontent.com/lukesampson/psutils/3290c04d7653ea8183a5e11d3d5a4e46716035d1/sudo.ps1 is not valid” 反复几此安装和卸载后,情况还是一样。

网络原因,找个代理可以解决,科学上网

Lilidandan321 commented 4 years ago

求帮忙指点:我也是git commits 报错,错误提示跟 #150 号一样。 PS C:\Users\jll\Code\learn-git> git status On branch master

No commits yet

Changes to be committed: (use "git rm --cached ..." to unstage) new file: README.md

PS C:\Users\jll\Code\learn-git> git commit hint: Waiting for your editor to close the file... internal/modules/cjs/loader.js:586 throw err; ^

Error: Cannot find module 'D:\D' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:584:15) at Function.Module._load (internal/modules/cjs/loader.js:510:25) at Function.Module.runMain (internal/modules/cjs/loader.js:746:12) at startup (internal/bootstrap/node.js:282:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:759:3) error: There was a problem with the editor 'code -w'. Please supply the message using either -m or -F option.

根据老师的提示我进行了以下操作,检验Visual Studio Code 正常,但就是提交不了 1.用菜单打开Visual Studio Code 运行没问题。在命令行 code .运行也没问题。 2.PS C:\Users\jll> git config --list 运行结果:PS C:\Users\jll> git config --list user.name=Lilidandan321 user.email=2467764484@qq.com core.editor=code -w 运行后这三项都有。 3.执行scoop checkup 也正常。 PS C:\Users\jll> scoop checkup No problems identified!

neolee commented 4 years ago

@Lilidandan321 建议另开新 issue,你这个和别的不一样,你的 scoop checkup 里的几个问题都解决了,还出现这个错误比较独特。

Lilidandan321 commented 4 years ago

@Lilidandan321 建议另开新 issue,你这个和别的不一样,你的 scoop checkup 里的几个问题都解决了,还出现这个错误比较独特。

重新安装了一次就好了,谢谢老师。

gongzhigao commented 4 years ago

@Lilidandan321 建议另开新 issue,你这个和别的不一样,你的 scoop checkup 里的几个问题都解决了,还出现这个错误比较独特。

重新安装了一次就好了,谢谢老师。

我的还没有处理好,你重装了哪些内容。

Lilidandan321 commented 4 years ago

@Lilidandan321 建议另开新 issue,你这个和别的不一样,你的 scoop checkup 里的几个问题都解决了,还出现这个错误比较独特。

重新安装了一次就好了,谢谢老师。

我的还没有处理好,你重装了哪些内容。

我还没学这次编程课前就安装了Visual Studia Code,,后面又卸载了估计没卸载干净,后面重新安装git commit时出现了那个问题,,我这电脑也没啥东西所以就恢复了出厂设置,之后又重新按照老师的步骤把所有的都重新装了一遍,就好了。

gongzhigao commented 4 years ago

重装解决了问题

jiushijiushi commented 4 years ago

重装解决了问题

我出现类似的问题,准备重装Visual Studia Code,你们是如何重装的呢