Skip to content

Commit d3372ac

Browse files
committed
handle more abs paths
1 parent 7b9fc5b commit d3372ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/open.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"net/url"
7+
"path"
78
"path/filepath"
89
"strings"
910

@@ -106,8 +107,13 @@ func (r *RootCmd) openVSCode() *clibase.Cmd {
106107
switch {
107108
case len(inv.Args) > 1:
108109
directory = inv.Args[1]
110+
111+
// We explicitly use `path.IsAbs` (vs `filepath`) because only
112+
// Windows absolute paths may start without "/".
113+
isUnixAndNotAbs := workspaceAgent.OperatingSystem != "windows" && !path.IsAbs(directory)
114+
109115
// Perhaps we could SSH in to expand the directory?
110-
if !insideThisWorkspace && strings.HasPrefix(directory, "~") {
116+
if !insideThisWorkspace && (strings.HasPrefix(directory, "~") || isUnixAndNotAbs) {
111117
return xerrors.Errorf("directory path %q not supported, use an absolute path instead", directory)
112118
}
113119
if insideThisWorkspace {

0 commit comments

Comments
 (0)