FS#63250 - [code] not possible to launch using 'vscode://' prefixed URL

Attached to Project: Community Packages
Opened by Valantis Trigonis (valtrig) - Monday, 22 July 2019, 10:07 GMT
Last edited by Massimiliano Torromeo (mtorromeo) - Friday, 28 April 2023, 14:15 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Massimiliano Torromeo (mtorromeo)
Filipe Laíns (FFY00)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description: After installation, attempting to launch the application via a 'vscode://' prefixed URL fails, due to invalid content of the '/usr/share/applications/code-oss-url-handler.desktop' file. Specifically, the file contains a variable named @@URLPROTOCOL@@ which is not being replaced by the proper value, i.e. 'vscode', during installation.

Adding 's|@@URLPROTOCOL@@|vscode|g' to the relevant 'sed' invocation section in PKGBUILD should do the trick!

Additional info:
* package version: 1.36.1-1
* original feature request in upstream: https://github.com/Microsoft/vscode/issues/48528
* documentation: https://code.visualstudio.com/docs/editor/command-line#_opening-vs-code-with-urls

Steps to reproduce:
# echo 'this is a test' > /tmp/test
# xdg-open vscode://file/tmp/test
gio: vscode://file/tmp/test: The specified location is not supported
# sudo update-desktop-database
Error in file "/usr/share/applications/code-oss-url-handler.desktop": "x-scheme-handler/@@URLPROTOCOL@@" is an invalid MIME type ("x-scheme-handler/@@URLPROTOCOL@@" contains an invalid character in the subtype)
This task depends upon

Closed by  Massimiliano Torromeo (mtorromeo)
Friday, 28 April 2023, 14:15 GMT
Reason for closing:  Fixed
Additional comments about closing:  code-1.77.3-2
Comment by Matt Rixman (matrixman) - Monday, 24 August 2020, 23:13 GMT
I see this was closed as "fixed" but I installed the `vscode` package just a few days ago and I'm seeing the behavior described here. Modifying `MimeType=x-scheme-handler/code-oss` to `MimeType=x-scheme-handler/vscode` fixed it.
Comment by Matt Rixman (matrixman) - Saturday, 12 September 2020, 21:47 GMT
In preparation for the upcoming bug wrangling day I double-checked this. It is still the case.
Comment by David (huantian) - Saturday, 03 July 2021, 03:52 GMT
This issue still seems to occur, fixed by the method previously discussed in the comments.
Comment by prettyvanilla (prettyvanilla) - Friday, 30 September 2022, 16:43 GMT
This was originally fixed by replacing the `@@URLPROTOCOL@@` by `vscode` in the url handler desktop file as suggested, but then later effectively overwritten by a separate `sed` call to fix the `code-oss` scheme not working (https://github.com/archlinux/svntogit-community/commit/9512872685edc7feb49479af17c182d392a9bf4f).

The correct value to replace `@@URLPROTOCOL@@` with depends on what is set for `urlProtocol` in the product.json - since this is currently not being touched this would be the default scheme `code-oss`.
There have been relatively recent changes in the handling of the (GitHub) auth flow for the `code-oss` scheme specifically due to issues on Windows (https://github.com/microsoft/vscode/commit/b1fb11e18cbdd3aba09e4aef0b4be07c0731d86f), making the default slightly less ideal. I thus suggest either changing the `urlProtocol` in `product.json` to `vscode` and removing the added `sed` call again or making `code-oss` the main replacement string and adding a second scheme handler in addition so that the desktop entry then contains `MimeType=x-scheme-handler/code-oss;x-scheme-handler/vscode;`.

Loading...