Skip to content

Scripts fail to launch in debugger (or open in ISE) if working directory path contains spaces #94

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

Closed
durmiun opened this issue Feb 10, 2016 · 9 comments
Assignees
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@durmiun
Copy link

durmiun commented Feb 10, 2016

Example: D:\powershell code\Get-Something.ps1 will fail to launch with the following error:

d:\powershell : The term 'd:\powershell' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • d:\powershell code\Get-OutlookPublicFolders.ps1
  • - CategoryInfo          : ObjectNotFound: (d:\powershell:String) [], CommandNotFoundException
    - FullyQualifiedErrorId : CommandNotFoundException
    
    

launch.json contains the default settings (as of 0.4.0 release of Powershell extension):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "PowerShell",
            "type": "PowerShell",
            "request": "launch",
            "program": "${file}",
            "args": [],
            "cwd": "${file}"
        }
    ]
}

I have also tried placing the full path name in the cwd parameter, using escaped double quotes, single quotes, etc.

@daviwil
Copy link
Contributor

daviwil commented Feb 10, 2016

Perfect, thanks for filing this! Should be an easy fix.

@rkeithhill
Copy link
Contributor

We should switch to using PathIntrinsics to set the working dir and when we escape the script path, we also need to escape spaces (not just [ and ]). For now you should be able to work around this by specifying the full path with spaces escaped e.g.:

"program": "d:\\powershell` code\\Get-OutlookPublicFolders.ps1"

@rkeithhill rkeithhill added this to the 0.4.1 milestone Feb 10, 2016
@rkeithhill rkeithhill self-assigned this Feb 10, 2016
@daviwil
Copy link
Contributor

daviwil commented Feb 10, 2016

Ah yes! The back tick is the trick.

@rkeithhill
Copy link
Contributor

BTW this issue also impacts the "Open file in ISE" command. :-(

@daviwil
Copy link
Contributor

daviwil commented Feb 10, 2016

Ouch! That's OK, should be relatively easy to make a backtick escaper in JavaScript.

@rkeithhill
Copy link
Contributor

Hmm, I was planning on fixing it in PSES. Do you think it would be better to do in the extension JavaScript?

@daviwil
Copy link
Contributor

daviwil commented Feb 10, 2016

The debug program path issue will need to be fixed in PSES but the 'Open in ISE' command is done purely in TypeScript (for now)

@daviwil daviwil added the Issue-Bug A bug to squash. label Feb 10, 2016
@rkeithhill rkeithhill changed the title Scripts fail to launch if working directory path contains spaces Scripts fail to launch in debugger (or open in ISE) if working directory path contains spaces Feb 11, 2016
daviwil added a commit that referenced this issue Feb 11, 2016
…paces

Fixes #94 - specifically the Open in ISE issue.
@durmiun
Copy link
Author

durmiun commented Feb 11, 2016

Awesome, thank you for the quick turn around on this!

@daviwil
Copy link
Contributor

daviwil commented Feb 11, 2016

Keith is the man! We're planning to ship an update sometime next week with this fix and a few others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants