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

Support opening a file via the CLI starting with "file://" #25987

Closed
HerrVoennchen opened this issue May 5, 2017 · 18 comments
Closed

Support opening a file via the CLI starting with "file://" #25987

HerrVoennchen opened this issue May 5, 2017 · 18 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities linux Issues with VS Code on Linux verified Verification succeeded
Milestone

Comments

@HerrVoennchen
Copy link

HerrVoennchen commented May 5, 2017

  • VSCode Version: 1.12.1
  • OS Version: Ubuntu 16.04 LTS / i3WM / PCManFM FileManager

Steps to Reproduce:

  1. in file manager select a file and right-click open with vscode
  2. now vscode should appear with a file tab with the name of the file but no loaded content, editor pane is empty

auswahl_001

@HerrVoennchen
Copy link
Author

HerrVoennchen commented May 5, 2017

cross-check: works on MacOSX Sierra with Version 1.12.1

@HerrVoennchen
Copy link
Author

cross-check No. 2: do NOT work with the current insiders Version 1.13.0

@Tyriar
Copy link
Member

Tyriar commented May 8, 2017

Cannot reproduce on Ubuntu 16.10, some questions:

  • Do you have any errors in the devtools console? (Help > Toggle Developer Tools)
  • What does the tooltip say when you mouse over the empty package.json file?
  • Does opening the file in some other application using your particular file manager work fine?

@Tyriar Tyriar added linux Issues with VS Code on Linux info-needed Issue requires more information from poster labels May 8, 2017
@HerrVoennchen
Copy link
Author

Hi, thanks for the reply.

I'll try that and give you the info when I'm in the office in about an hour. I can tell you that the issue hits all files I tried so far and it work flawless with e.g. opening it in sublime.

@HerrVoennchen
Copy link
Author

HerrVoennchen commented May 9, 2017

the released version had no errors or anything severe in the console.

the insiders version throw some errors. logs attached. The smaller file is from the insiders version from yesterday, the other from today's version.

the path it self is correct, though i cannot say if the string composition is because I have very limited knowledge about electron.

Hope it helps.

-1494312204502.txt
-1494312641624.txt

Edit: it works with Nautilus from Unity but PCManFM seems to have trouble to pass the argument to the editor correctly? (weird guess)

@Tyriar
Copy link
Member

Tyriar commented May 9, 2017

Here's the error for this:

ENOENT: no such file or directory, stat '/home/kruemling/file:/media/kruemling/Daten/dev/git/roche-contract-mgmt'

Looks like a file:/ is being jammed in there, maybe we could make the URI parsing logic more robust to fix this? Or it could just be a big in PCManFM.

Maybe you could try editing the desktop entry to write the file path to a file so we can inspect it?

Try opening the file /usr/share/applications/code.desktop and changing the Exec line from this:

Exec=/usr/share/code/code --unity-launch %U

To something like this:

echo "%U" > ~/testfile

Then inspecting what %U is output as in ~/testfile?

@HerrVoennchen
Copy link
Author

HerrVoennchen commented May 9, 2017

I'll try that when I'm in the office tomorrow. I set up a VM with ubuntu 17.04 and my basic setup and i can reproduce the error there but I have trouble to get that testfile created. It just won't work, idk. No error, nothing. The file just won't be created.

If you're interested I can send you that VM somehow (about 5.3 GB).

regarding that path, it's pretty weird.

/home/kruemling <- that is my home directory but I never saw this as a prefix part to a path

/file: <- I assume file is the uri prefix for the path?

/media/kruemling/Daten/dev/git/roche-contract-mgmt <- this is the real path to the directory where the package.json is located

@Tyriar
Copy link
Member

Tyriar commented May 9, 2017

@HerrVoennchen yes please try in the office 😃 if you can't get that to work try tweaking it to give you the info some other way.

file:/ is likely being added by us, which makes me wonder what is being sent to vscode.

@HerrVoennchen
Copy link
Author

HerrVoennchen commented May 11, 2017

sry for the delay. stayed sick at home. I tried to get the parameter in my VM since its reproducable there. I wrote a bash script to get that info.

%U results in 'file:///media/sebastian/VBOXADDITIONS_5.1.22_115126/64Bit/Readme.txt'

I had to use another file since my VM is empty.

still curious why in vscode my home path gets in front of the uri prefix.

Edit: for consistency here is the match log to that file I tried to open here

-1494499830289.txt

@Tyriar
Copy link
Member

Tyriar commented May 11, 2017

I can reproduce by running this:

code-insiders file:///Users/daimms/dev/Microsoft/vscode/package.json

Mousing over the file it reads:

~/dev/Microsoft/vscode/file:/Users/daimms/dev/Microsoft/vscode/package.json

So basically the bug is that it doesn't know how to parse file://, at least when going via the CLI.

@Tyriar Tyriar changed the title Open file from filemanager don't work Support opening a file via the CLI starting with "file://" May 11, 2017
@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels May 11, 2017
@Tyriar
Copy link
Member

Tyriar commented May 11, 2017

@bpasero FYI, this might be a one line fix

@bpasero
Copy link
Member

bpasero commented May 12, 2017

Can I ask why a program would send the file:// URI to VS Code and not just the file path? Are you sure any other application supports file:// URI as command line argument?

I would behave like native apps do and only support what they support. ls for example does not support file URIs:

image

@bpasero bpasero added feature-request Request for new features or functionality workbench and removed bug Issue identified by VS Code Team member as probable bug labels May 12, 2017
@bpasero bpasero removed their assignment May 12, 2017
@HerrVoennchen
Copy link
Author

Over the why you have to ask the guys from pcmanfm. But it's not that uncommon. And ls is a pretty bad example. All text file opening applications installed on my machines can handle Uri format except vscode.

@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label May 15, 2017
@Tyriar Tyriar added this to the Backlog milestone May 15, 2017
@ghost
Copy link

ghost commented Jun 20, 2017

I also encountered the problem. My os is Fedora 25 - lxde with pcmanfm. I think the problem is with %U. If you change it to %F, it will work without the prefix "~/file:". I am not sure how it will behave with other file managers or distros.

@cefn
Copy link

cefn commented Jul 24, 2017

+1 for changing the code.desktop file in the .deb package so it doesn't request a file specification from the file manager that it can't handle. This is presumably easier in the short term than the work for vscode to be updated to handle file:// uris correctly. If there is some long term benefit from passing file paths as URIs then %U it can be reinstituted in code.desktop when supported.

I'm not sure why %U would have been specified in the first place, and what potential benefit there is. PCManFM can send a normal file path, by changing to %F in the .desktop file as per #31284 following https://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

@Tyriar
Copy link
Member

Tyriar commented Jul 31, 2017

@cefn thanks for the advice, made the change 😃

@Tyriar Tyriar modified the milestones: July 2017, Backlog Jul 31, 2017
@Tyriar Tyriar closed this as completed in 2c74500 Jul 31, 2017
Tyriar added a commit that referenced this issue Jul 31, 2017
@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug and removed feature-request Request for new features or functionality workbench labels Jul 31, 2017
@Tyriar
Copy link
Member

Tyriar commented Jul 31, 2017

To verifier: You need PCManFM FileManager installed to reproduce this.

@HerrVoennchen
Copy link
Author

coincidentally I have one :D

@chrmarti chrmarti added the verified Verification succeeded label Aug 2, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
lemanschik pushed a commit to code-oss-dev/code that referenced this issue Nov 25, 2022
%U may pass in file:// format which isn't supported.

Fixes microsoft#25987
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities linux Issues with VS Code on Linux verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants