Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

gorename path error - file not found when git diff in windows path #665

Closed
sdwarwick opened this issue Nov 29, 2016 · 15 comments
Closed

gorename path error - file not found when git diff in windows path #665

sdwarwick opened this issue Nov 29, 2016 · 15 comments

Comments

@sdwarwick
Copy link

sdwarwick commented Nov 29, 2016

attempting to perform a "rename symbol", I am getting the following error:


File not found (\"C:\Users<valid path>\file.go")

this happens on workspace or individual file settings.
I've tried changing the environment variables to remove the C: but everything stops working then.

note the backslash before the quote.
cannot seem to find any other settings that impact this.


windows 10
VSCODE 1.7.2
NODE 6.5
extension version: 0.6.50 - 21st November, 2016

@ramya-rao-a
Copy link
Contributor

Can you share your GOPATH if you have set any in the settings ? If not then share the GOPATH from your environment variables.

gorename and guru are the 2 tools we use that expect the filepath passed to them to have the exact casing and slashes (forward/backward) as the GOPATH being used.

Also, can you share the complete error message? Does it start with "Cannot rename due to errors..." ?

@sdwarwick
Copy link
Author

sdwarwick commented Nov 29, 2016

the complete error message is as shown. I did a copy/paste. it is preceded by a red "error" box
GOPATH:
C:\Users\xxx\Google_Drive\golang;C:\Users\xxx\Google_Drive\projects\project name\application

note that "project name" is a directory name which has a real space between two words as shown.
the actual files are in a sub-directory of application:

application\src\mypackagename/*.go

space in path proven not to make a difference

@ramya-rao-a
Copy link
Contributor

If you didnt see the error message Cannot rename due to errors: then that means that the gorename tool ran successfully and the Go extension has returned the file edits to make to VS Code. VS Code in turn was not able to find the file and so you see the error File not found ()

Do you see any errors in the console? Open Developer: Toggle Developer Tools to see the console.

Does this happen on all of your Go projects?

@sdwarwick
Copy link
Author

from the debug console:

File not found (\"C:\Users\xxx\Google_Drive\projects\directory name\application\src\pkgname\afile.go")

/C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:90 

all of my projects are under this directory structure, and are all experiencing this problem.

@ramya-rao-a
Copy link
Contributor

The slash before the quotes is the problem. I know you mentioned that earlier, but the error message you pasted didnt have the slash, so I didnt make the connection.

Since I can't repro this, can you download the code for the Go extension and debug locally?
I can walk you through it, it is very simple.

Close all instances of VS Code and run the below in your command prompt

git clone https://github.com/Microsoft/vscode-go
cd vscode-go
npm install
code .
  • VS Code will open with the source code for the Go extension.
  • Put a breakpoint in line 51 in the file gorename.ts
  • Press F5, the new VS Code window will open. Open your Go project in this VS Code window
  • Rename something, the breakpoint will be hit. See what is the value for filePatch.fileName

@sdwarwick
Copy link
Author

sdwarwick commented Nov 29, 2016

this is great - I have followed your instructions. the filePatch.fileName has the slash in front..

"\"C:\\\\Users\\\\xxx\\\\Google_Drive\\\\projects\\\\dir name\\\\application\\\\src\\\\dname\\\\fname.go\""

would it be helpful to set up a chat to work through this?

@sdwarwick
Copy link
Author

sdwarwick commented Nov 29, 2016

I have moved the breakpoint up to buildTags.. it is returning the following:

"\"\""

I have checked all of my workspace and user settings.json files.. I have nothing like this. I've cleared the settings files and still get it.

@ramya-rao-a
Copy link
Contributor

buildTags doesn't matter. You say you see the slash in the front, but what you pasted doesn't have it. Are you sure?

""C:\Users\xxx\Google_Drive\projects\dir name\application\src\dname\fname.go""

Add a breakpoint at line 26 and check what is the value of document.fileName and filename.
Are you on gitter ? If not, you can join https://gitter.im/Microsoft/vscode-go and we can chat there to work through this.

@sdwarwick
Copy link
Author

the forward slash was actually there, but github mistook it for markup!!! I changed it to "code" so it would show up.. sorry

@ramya-rao-a ramya-rao-a changed the title gorename path error - file not found gorename path error - file not found when file path has space Nov 29, 2016
@sdwarwick sdwarwick changed the title gorename path error - file not found when file path has space gorename path error - file not found when git diff in windows path Nov 30, 2016
@sdwarwick
Copy link
Author

It has been shown that when git for windows is installed in the standard windows path, the vscode-go integrated gorename function breaks due to a slight difference in output from other diff implementations.

changes to support a diff string with quotes around the file path is requested.

@rotemdan
Copy link

@sdwarwick @ramya-rao-a

I had this exact problem. Thanks to your research it quickly led to the reason: I had the Cygwin tools bundled diff executable in my PATH. I renamed the diff.exe executable to diff.exe.disabled and the problem was solved. So in my case it wasn't actually related to Git for windows.

This leads me to wonder, if there are multiple incompatible versions of diff utilities. Is it really safe to use just any executable that's available in the PATH?

Perhaps a setting entry like go.useExternalDiffTool (boolean) or even go.diffToolPath (string) should be required to be set by the user for the external utility to be used?

@sdwarwick
Copy link
Author

I'm thinking that any hidden dependency on other tools in the path is just bad practice. this has been sitting out here without action for a while now.

@ramya-rao-a
Copy link
Contributor

I'll pick this up for the next update in March

@ramya-rao-a
Copy link
Contributor

Logged kpdecker/jsdiff#171 for the root cause.
Fixing from our end via #866

Sorry this took a while :(

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Mar 30, 2017

The latest update (0.6.56) to the Go extension has the fix to this issue

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants