microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.46k stars 821 forks source link

WSL - Won't open PowerShell unless sudo is used. #1315

Closed MaximoTrinidad closed 6 years ago

MaximoTrinidad commented 8 years ago

Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs!

sudo powershell

This was working fine with Ubuntu 14.04. The workaround still works except now I have to use 'sudo powershell'.

(http://www.maxtblog.com/2016/10/running-powershell-in-windows-10-bash-workaround/ )

The shell cannot be started. A failure occurred during initialization: Access to the path '/home/maxt/.local/share/powershell/Modules' is denied. maxt@MTrinidadLT2:~$

bashposherr_2016-11-03_10-15-43

See our contributing instructions for assistance.

fpqc commented 8 years ago

Hooold on, you're doing something that you're not telling us.

You can't launch powershell like that unless you either aliased it or added something to your PATH, but more likely aliased (since you're starting without the ".exe").

Let's begin at the beginning.

benhillis commented 8 years ago

@fpqc He's running the Linux version of powershell.

MaximoTrinidad commented 8 years ago

Yes @benhillis! You are correct. I'm running Linux version of PowerShell (no exe included). And, this was opening fine when using Bash (Ubuntu 14.04). :)

ddfznt commented 8 years ago

@MaximoTrinidad sudo chown -R maxt ~/.local

MaximoTrinidad commented 8 years ago

@ddfznt Ouch!! This will work around the issue and I don't know how much is will impact using PowerShell. But, very interesting!

bashposherr2_2016-11-03_10-15-43

Thanks, Max

ddfznt commented 8 years ago

@MaximoTrinidad https://github.com/Microsoft/vscode/issues/6684 take a look here!

MaximoTrinidad commented 8 years ago

Hi @ddfznt! Thanks but that issue is not related. That's on using VS Code Windows OS not BASH. I have not problems with VS Code running PowerShell Core on either Windows 10 nor Linux. It's just with the recent BASH update. :)

sample "Terminal working fine". bashnorelated_2016-11-03_14-17-50

andrewfinnell commented 8 years ago

Am I to understand you're attempting to spawn a Powershell instance while under the WSL bash.exe instance? I'm curious what the use case is for this and if you're able to run a cmd.exe which then spawns Powershell.

I didn't think Windows PE binaries were launchable from within WSL. Is this new or was I just blind?

fpqc commented 8 years ago

@afinnel it was announced to much fanfare like 2 weeks ago.

MaximoTrinidad commented 8 years ago

This is the thing!

Yes, you can launch Window binaries from WSL. But, this is what I found out today.

For example, you are creating a cross-platform PowerShell script and launch Windows VS Code (from Bash) to create the file in the Linux subsystem, it won't be visible in Bash. It will be visible in Windows Explorer and Windows VS Code.

Try to use the Nautilus to look for the file created in Windows VS Code, and you won't find it. So, for me, I can't use the Windows Version of VS Code to create PowerShell scripts in Bash Linux subsystem.

Also, if I create a PowerShell script file using 'gedit' and then use Windows VS Code to change it., then I won't see the file in Bash again.

Now, back to the topic. Beside the known display issue with PowerShell, I could open it without using 'sudo' before Bash got upgraded to Ubuntu 16.04.1.

I'm suspecting something with the user profile permission.

:)

fpqc commented 8 years ago

It will work as long as it's on a volume mounted in /mnt

MaximoTrinidad commented 8 years ago

@fpqc

No! I want to have a workable PowerShell Core (Linux) on Bash so I can test cross-platform PS scripts.

Anyway, I just tested executing the Windows PowerShell in Bash using: "/mnt/c/Program Files/PowerShell/6.0.0.12/powershell.exe"

It doesn't work. I won't use it that way but it was good to try it.

:)

benhillis commented 8 years ago

Can you clarify what you mean by doesn't work?

MaximoTrinidad commented 8 years ago

Hi @benhillis,

After you enter "/mnt/c/Program Files/PowerShell/6.0.0.12/powershell.exe", the PowerShell prompts comes up OK.

  1. Then, enter $psver -press tab and it doesn't autocomplete to $psversiontable. It just does a tab.
  2. Up arrow to get back to previous command won't work.
  3. Do a "Dir c:\Windows\System32", try to do a Ctrl-C to stop the listing. it won't stop.
  4. Sometimes if you mistyped a command and go back to fixed it then it still won't work.
  5. In PowerShell.exe I use the 'cls' alias and got me out to the bash prompt. But, not sure where I'm at this point because it keeps jumping from PowerShell to Bash back to PowerShell.

wposhinbash_01_2016-11-04_10-19-22 wposhinbash_02_2016-11-04_10-19-22 wposhinbash_03_2016-11-04_10-19-22 wposhinbash_04a_2016-11-04_10-19-22 wposhinbash_04b_2016-11-04_10-19-22

At this point I rather not use Windows PowerShell.exe in Bash.

But, I definitely have more control in PowerShell Core (Linux) when using 'xterm' in Bash using sudo.

MaximoTrinidad commented 8 years ago

Of course, I'm using Xming, and configure xterm to allow scrolling.

xterm2posh_2016-11-04_10-53-19

benhillis commented 8 years ago

@MaximoTrinidad Thanks for the feedback. The limitations you mention in 1, 2, 4, and 5 are due to the way console handles are currently managed. I have a thread with @bitcrazed @zadjii-msft and @miniksa to see the best way to resolve those issues.

Issue 3 is more related to the difference between the way Linux and Windows processes handle control c. I have a task on my backlog to look into this.

MaximoTrinidad commented 8 years ago

This is Awesome! Thanks. I started to show the work around and record my UG meeting on using Bash and PowerShell Core (Linux). I know there are limitations but at least (for me) using xterm is a winner to some UX win. I like the cross-platform collaboration.

Again, a clean Bash installation, follow by loading PowerShell Core, there's a message coming up when executing 'powershell' (w/o sudo). I couldn't print the screen but it seem couldn't load some modules and it looks related to user profile issue. I will rebuild my bash on my other machine to trap the error.

I like the direction this is heading! :)

fpqc commented 8 years ago

@maximotrinidad, you should use wsltty , which uses mintty instead of xterm

bitcrazed commented 8 years ago

@fpqc That's just a work around. We should also fix our stuff if possible!

fpqc commented 8 years ago

@bitcrazed Of course, but it is preferable to xterm over X over TCP. It can at least use local fonts. Also, I was trying to figure out the markdown syntax for linking another repo, it is:

[linktext](/username/repo)

You can also manipulate the path like any old path, so you could do:

vscode issues

which in markdown looks like

[vscode issues](../../vscode/issues)

No more c&p URLs on a phone for me!

MaximoTrinidad commented 8 years ago

Thanks @fpqc for recommending wsltty. I will check it out! :)

benhillis commented 6 years ago

Closing this out as the issues with interop console handles is being tracked elsewhere.