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

"No such file or directory": problem with gitbash in Windows 10 #2

Open
stevenkkim opened this issue Jun 15, 2018 · 27 comments
Open

"No such file or directory": problem with gitbash in Windows 10 #2

stevenkkim opened this issue Jun 15, 2018 · 27 comments

Comments

@stevenkkim
Copy link

I'm using vs code on Windows 10, but I'm using gitbash as my integrated terminal instead of the Windows shell.

When using either the "Open in Integrated Terminal" or "Open Root in Integrated Terminal" commands, the directory is not found because the directory slashes are backslashes (Windows-style) instead of forward slashes (bash-style)

Upon opening the terminal, the following output is shown:

cd c:\Users\Steven\Dev\selenium.js
bash: cd: c:UsersStevenDevselenium.js: No such file or directory

If I type manually type "cd c:/Users/Steven/Dev/selenium.js" in the integrated terminal, then the cd command works.

@stevenkkim
Copy link
Author

FYI, it looks like the extension terminal-here (https://marketplace.visualstudio.com/items?itemName=Tyriar.vscode-terminal-here) works in gitbash in the integrated terminal on Windows. If you look at the code here:

https://github.com/Tyriar/vscode-terminal-here/blob/master/src/extension.ts

the relevant code is this:

        switch(kindOfShell(vscode.workspace.getConfiguration('terminal'))) {
            case "wslbash":
                // c:\workspace\foo to /mnt/c/workspace/foo
                dir = dir.replace(/(\w):/, '/mnt/$1').replace(/\\/g, '/')
                break;
            case "cmd":
                // send 1st two characters (drive letter and colon) to the terminal
                // so that drive letter is updated before running cd
                terminal.sendText(dir.slice(0,2));
        }

        terminal.sendText(`cd "${dir}"`);

@stevenkkim
Copy link
Author

Sorry, I just noticed one more thing... when I use the terminal-here extension, the terminal command says:

cd "c:\Users\Steven\Dev\selenium.js"

which works with the backslashes. So fixing this bug may be as simple as enclosing the directory path in double quotes.

@fabiospampinato
Copy link
Owner

Thanks for reporting the issue, I don't really use Windows nor git bash so I'm not too surprised to see these incompatibilities. I'll address the problem when I'll have the time.

Ps. I think you should use a "real" terminal instead, like bash or zsh, running under WSL.

@stevenkkim
Copy link
Author

Thanks Fabio. I did try WSL a while ago when it first came out, but there were too many bugs at the time. Also, sharing files between the Windows filesystem and Linux subsystem was a pain. It's possible to symlink Linux to Windows, but not vice versa. But maybe they have fixed those issues since. Git bash, while not "real bash" does a surprisingly good job emulating bash on Windows and is very lightweight. It's the best terminal shell on Windows in my opinion. WSL and Cygwin were too heavy and complicated. And I certainly don't want to learn Powershell.

@fabiospampinato
Copy link
Owner

I'm sorry but I didn't have the time to try to fix this, if anyone could help with this I'd appreciate it.

@neelam0026
Copy link

@stevenkkim I am facing the same issue as you have and I am new user for this github so kindly help regarding the same issue faced by me

@neelam0026
Copy link

Issue : "No such file or directory": problem with gitbash in Windows 10 #2 if you find the solutions for it please let me know.

@ahull002
Copy link

ahull002 commented Aug 5, 2019

Sorry, I just noticed one more thing... when I use the terminal-here extension, the terminal command says:

cd "c:\Users\Steven\Dev\selenium.js"

which works with the backslashes. So fixing this bug may be as simple as enclosing the directory path in double quotes.

Hi, this also worked for me as well: wrapping the dir in double-quotes somehow worked! Thank you so much for your help!

@Fabricoholic
Copy link

Fabricoholic commented Mar 4, 2020

Hi !

I had the same problem. It worked with the double quotes too. No clue why aha but wanted to say it works!

@ahad-alselmi
Copy link

Sorry, I just noticed one more thing... when I use the terminal-here extension, the terminal command says:

cd "c:\Users\Steven\Dev\selenium.js"

which works with the backslashes. So fixing this bug may be as simple as enclosing the directory path in double quotes.

yes your suggestions work with me your are very smart thank you.
for git team the problem still until 2021

@Himanshunitrr
Copy link

There are other extensions which use backslash. The git team must solve this bug asap.

@TheGreat-Gazoo
Copy link

For me it was an issue with OneDrive in the directory. When I removed OneDrive from the directory it worked.

@Shoaib-Cheema
Copy link

Sorry, I just noticed one more thing... when I use the terminal-here extension, the terminal command says:

cd "c:\Users\Steven\Dev\selenium.js"

which works with the backslashes. So fixing this bug may be as simple as enclosing the directory path in double quotes.

Ahhhhhh you are a legend man!!!!!!!!!!!!!! You saved me what ive been tryna do for soooooo long

@RiyaadHossain
Copy link

I am facing the same issue
it's so disappointing.

@pasangeek
Copy link

may be its associate with another file sharing platform in my case desktop is sync wit the one drive so i add file path as this cd "C:\Users\pasan\OneDrive"

@developerasun
Copy link

Same problem here.

When directory exists,

exists

git bash fails to change directory.

path

@shubhamsurve96
Copy link

you saved me bro..
god bless you

@abaynew-guadie
Copy link

my error is this how to fix it??
bash: /home/daygeek/betty/main.rb: No such file or directory

@jaimeserranodev
Copy link

Hi,
When you put that code after cd the address has to be with quotes " ". Try with this line:
cd "/home/daygeek/betty/main.rb:"

@forodo
Copy link

forodo commented Mar 26, 2023 via email

@jens-ofzo
Copy link

So what worked for me here is typing it out by hand. When I copied the directory it was missing the ":" between my "c" directory and the "/" which is what made it mess up. I believe @stevenkkim wrote a similar response

@MamontshengS
Copy link

I tried so many different ways still says No such file or directory

@SandraLarsen
Copy link

https://www.youtube.com/watch?v=AdzKzlp66sQ
Opening git bash from the folder solved this issue for me

@444novaaa
Copy link

For me I realized I actually had the contents that I wanted inside of an extra folder, so go to your files and make sure it's exactly where you think it is

@fabiospampinato
Copy link
Owner

I've just rewritten the extension, can anybody check if this is fixed in v2?

I think it should be because I'm passing the cwd to vscode directly, rather than executing cd command. Which should also speed things up slightly and declutter the terminal.

@euginekoyo
Copy link

am getting this error

HP@HACKBOOTH245 MINGW64 ~
$ cd "c:\xampp\htdoc\app.com\src\App.js"
bash: cd: c:\xampp\htdoc\app.com\src\App.js: No such file or directory

@fabiospampinato
Copy link
Owner

@euginekoyo It looks like you are on v1, you'd need to updated to v2 to see this fixed. You might need to upgrade vscode to be able to upgrade to v2.

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

No branches or pull requests