Launching Explorer from WSL - windows

start . is used to launch an explorer window from cmd.
When doing the same from wsl, I get
$ start . start: Unable to connect to system bus: Failed to connect to
socket /var/run/dbus/system_bus_socket: No such file or directory
Is there an easy way to fix this?

Since Creators Update you can call Windows executables from WSL if you add the extension file. You can open the present folder like this.
explorer.exe .
If you still need start then you can create an alias
alias start='cmd.exe /c start'
then start . will work too.

You can call Windows executables from WSL but you should add the extension of the file too. also there is another problem that in wsl when you want to open a directory in the file explorer, you should use explorer.exe \\home\\username\\projects\\ command because windows cannot understand linux standard path slashes. so, I made a wrapper to solve all of these problems. this project is a wrapper between the Linux command-line and windows file-explorer that converts / to \\.
with this wrapper you can interact with the windows file-explorer exactly like the linux-native one. the below box exhibits the way you can open file explorer using this wrapper.
explorer /home/

Related

Open Linux subsystem directory v.s. raw Windows directory in VS Code?

I want to open a WSL directory in VS Code. What's the difference between the following two methods and which should I use?
First method, open WSL window. It's common.
Second method, directly open directory and select the directory in wsl$ path.
Visual Studio Code recognize better the Connection than opening it directly
In most cases, you'll want to use the "New WSL Window" (or its equivalent). This utilizes the "Remote - WSL" extension to connect to your WSL instance through a small server that it installs in your WSL user's home directory. You'll probably find it already installed in your case in ~/.vscode-server.
This server handles the "translation" between the Windows VSCode and the Linux files, folders, and processes.
An easy way to think about the difference between the two methods of opening a folder:
Using "New WSL Window" puts VSCode in "WSL/Linux" mode
Using "Open Folder" and opening \\wsl$\... directly keeps VSCode in "Windows mode".
Comparing the two techniques with a real file. I have a simple Python file in my WSL home directory that I wrote up for another answer a few days ago. If I:
Open my home directory through \\wsl$\ in VSCode, then the VSCode Python extension complains:
Python is not installed. Please download and install Python before using the extension.
Since I don't have the Windows version of Python installed, and VSCode is operating in "Windows mode", it can't find the Linux/WSL Python interpreter.
However, if I:
Open my home directory through "Remote-WSL: New WSL Window", then open my Python file, then VSCode finds my Python interpreter, and I can run and debug the file in WSL through VSCode.
Side note #1: There is another method that has the same effect as using the command palette's "New WSL Window" -- From inside a WSL directory, run code .
Side note #2: There may be times when you want to open a file that lives inside WSL in "Windows mode". You may want to run it in a Windows version of a tool (Python, Java, whatever) to check compatibility.
As a general rule of thumb, however, you should probably do your Linux development with files inside WSL using VSCode's "WSL Mode" and Windows development with files that live on a Windows drive using "Windows (a.k.a. normal) mode".

How to open Anaconda Prompt from Windows Explorer URL?

I would like to open the Anaconda Prompt within a current folder using the URL in Windows Explorer similar to how you open a Git Bash terminal using "git-bash here".
I was unable to find a way to do this.
I tried to add the installation directory to the system PATH variable but that didn't work.
Any ideas if this is possible?

Is there a way to access a WSL folder from the Windows host or vice versa?

I've Windows 2010 home ed installed and on top i have installed Ubuntu extension support by Windows.
I've started wrting my project there but not sure
how to access directory in Ubuntu from my windows system (host)
any thoughts? Thanks in advance
I'd prefer to not use any external tool for it.
In Windows10 after the may 2019 update, the expected way to access WSL files from windows is via the mounted network drive.
You can access it at \\wsl$\<distro> via explorer, etc. You can even just launch explorer from wsl by running explorer.exe from your WSL shell.
See the dev blog post here for more info: https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-windows-10-version-1903/
To access the Windows10 filesystem you can just use the mounted filesystem at /mnt/<drive_letter> in WSL
figured out lately and as mentioned by #imbuedHope, from wsl command bash shell, you can open current directory by specifying . as follows:
explorer.exe . //notice the dot
then u could navigate using windows explorer to wherever u want.
In Windows 11 Home, the Linux/Ubuntu folder automatically shows up in Windows Explorer.
In Linux/Ubuntu, the Windows filesystem shows up under /mnt/<mountname>/c. [The "mountname" was a choice provided during the WSL2 installation.] I can access Windows "My Documents" folder through the path: /mnt/arun/c/Users/arun/Documents/.

Have WSL shell open to project directory in Windows Visual Studio Code

I have a windows subsystem for Linux Installed on my computer and am using it as the integrated terminal on Visual Studio Code. Every time I open a terminal however, it opens in the root directory rather than the current project directory like other terminals do.
Does anyone know of a fix for this?
I have tried messing with the Cwd of the integrated terminal settings but haven't had any luck.
Try using wsl.exe as the command for shell.
"terminal.integrated.shell.windows": "wsl.exe"
I know that is very late for this answer, but for me it just worked.
I put exactly as above and it launched in my home directory (that is /mnt/d/Users/Adrian).
I have the user setup of VSC, 1.30.1 and launch it from the Desktop shortcut.
After I configured terminal as wsl I go as below:
If I open a cmd windows I can launch it with code . it will launch in Windows home directory.
If move to some other folder (e.g Documents) and launch it with code . the bash will launch to that folder.
Otherwise I can launch it with code D:\Users\Adrian\Documents\VSC and the bash terminal will launch in \mnt\D\Users\Adrian\Documents\VSC
Tested the change both via menu File->Preferences->Settings and with Ctrl+Shift+P (Command Pallete), Terminal: Default Shell.
Tried with bash and wsl.
Maybe you have some other bash installed in the path? (e.g. git bash or MinGW bash?)

Bash on Windows - debug a python file with Visual Code or Visual Studio

I have a python file in my Bash on Windows environment.
Is it possible to debug it with Visual Code or Visual Studio?
Can a debugger be attached to the Linux python version that exists in the Bash on Windows environment?
I think you've got a few options for this. If you're attempting to debug a python file that's saved on your home directory in Bash on Windows, you can navigate to your home directory in Windows by going to "C:\Users\[windows username]\AppData\Local\lxss\home\[ubuntu username]\". Then you can open any of your projects or files saved on your home folder in Ubuntu. You can even make a shortcut on your desktop or something to make it easier to access this folder.
However, if you need the environment that you have on Bash for dependencies or python modules, your other option is to install a GUI and Linux-compatible IDE of your preference on Ubuntu, and use Xming on Windows to run the IDE on your screen. A tutorial on how to do this can be found here.
If you need to debug a linux python program from Visual Studio, a simple Google search yielded this. I haven't tried it but this seems to be the solution you are looking for. For connecting over the network to Bash on Windows from Windows, use localhost for the host.
Your best bet might be to just move the file. Your normal windows system is mounted under /mnt/c.
You can just copy it to your desktop by doing
cp (path to your file) /mnt/c/(your username)/Desktop
When you need to access or edit it from bash, just cd to that location (or wherever else you choose to store it).
Interesting other idea: you could mount cloud storage (e.g. google drive) via fuse in linux then set it up in windows. Copy the python to it and you can edit in windows and access in linux as needed. (Google is your friend here; look into google-drive-ocamlfuse or gdrivefs).
Hope this helps!
jBit
I would suggest making use of the Remote - WSL extension for Visual Studio code. It allows you to easily access your Windows Subsystem for Linux (WSL) and use it as a full-time dev environment.
Here is an article on how to set up Visual Studio Code Remote-WSL.
After that is set up, you can quickly load your python file in the VS Code editor using a command like: code path/to/python_file.py

Resources