From 26d83a6f7df87ee6d478b8651f0672568c4dc6e4 Mon Sep 17 00:00:00 2001 From: maxdevjs <22229196+maxdevjs@users.noreply.github.com> Date: Wed, 29 Dec 2021 03:18:28 -0300 Subject: [PATCH 1/6] Update Remote Containers link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6947ca7..deeab1c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This repository is intended for scripts and hooks to integrate [Toolbox](https:/ In particular, it provides a `code.sh` script that: * If necessary, prompts to install the Flatpak of Visual Studio Code - * If necessary, configures the current toolbox container to work with the [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote) Visual Studio Code extension. + * If necessary, configures the current toolbox container to work with the [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) Visual Studio Code extension. * Opens a VSCode window using the remaining command line arguments Installation From 64aa531399c0e1742dc6f05ebff3c5edbefb2458 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 7 Mar 2022 13:03:24 -0500 Subject: [PATCH 2/6] Add --ms-enable-electron-run-as-node When opening another window in the same process, we need to update the cut-and-paste code from the wrapper to also include --ms-enable-electron-run-as-node. See: https://github.com/flathub/com.visualstudio.code/pull/269 https://github.com/microsoft/vscode/issues/136987#issuecomment-966914578 Fixes: #19 --- code.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/code.sh b/code.sh index 4a8c729..390c651 100755 --- a/code.sh +++ b/code.sh @@ -459,6 +459,7 @@ else $verbose && set -x $flatpak enter "$existing" sh -c "$script" "$PWD" "$HOME" \ /app/extra/vscode/code /app/extra/vscode/resources/app/out/cli.js \ + --ms-enable-electron-run-as-node \ --extensions-dir="$HOME/.var/app/com.visualstudio.code/data/vscode/extensions" \ --remote attached-container+"$container_name_encoded" "${new_args[@]}" fi From 570287066c565dcf4695173fd33e0d020019a808 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 7 Mar 2022 13:20:56 -0500 Subject: [PATCH 3/6] README.md: document creating ~/.local/bin if it doesn't exist Suggestion from Hannes Kuchelmeister Fixes: #15 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index deeab1c..6b950d8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Installation ``` git clone https://github.com/owtaylor/toolbox-vscode.git cd toolbox-vscode +[ -d ~/.local/bin ] || mkdir ~/.local/bin ln -s "$PWD/code.sh" ~/.local/bin/code ``` From 996df0a755baa2a775d3a659f9b5129be2775230 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 7 Mar 2022 13:39:05 -0500 Subject: [PATCH 4/6] Fix tests for --ms-enable-electron-run-as-node addition --- tests/test-basic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-basic.sh b/tests/test-basic.sh index 413b150..5d5deb1 100644 --- a/tests/test-basic.sh +++ b/tests/test-basic.sh @@ -114,6 +114,6 @@ flatpak enter 123456 sh -c ELECTRON_RUN_AS_NODE=1 \ PATH="${PATH}:$XDG_CONFIG_HOME/node_modules/bin" \ exec "$@" - /home/testuser/project /home/testuser /app/extra/vscode/code /app/extra/vscode/resources/app/out/cli.js --extensions-dir=/home/testuser/.var/app/com.visualstudio.code/data/vscode/extensions --remote attached-container+746f6f6c626f782d7673636f64652d74657374 /home/testuser/project + /home/testuser/project /home/testuser /app/extra/vscode/code /app/extra/vscode/resources/app/out/cli.js --ms-enable-electron-run-as-node --extensions-dir=/home/testuser/.var/app/com.visualstudio.code/data/vscode/extensions --remote attached-container+746f6f6c626f782d7673636f64652d74657374 /home/testuser/project EOF } From 43662e757d82d526490b46816d93ecb5ae6144dd Mon Sep 17 00:00:00 2001 From: Sander Pikhoff Date: Thu, 24 Feb 2022 17:59:59 +0200 Subject: [PATCH 5/6] Fix unterminated quoted string error when running podman v4 Release candidates of podman v4 are unable to handle escape sequences inside strings. See: https://github.com/containers/podman/issues/13446 Work around this by using the println function instead. --- code.sh | 2 +- tests/test-basic.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code.sh b/code.sh index 390c651..b9d7085 100755 --- a/code.sh +++ b/code.sh @@ -298,7 +298,7 @@ fi # different toolboxes step on each other. homevar="$(flatpak-spawn --host podman inspect "$container_name" \ - --format='{{ range .Config.Env }}{{ . }}{{"\n"}}{{ end }}' \ + --format='{{ range .Config.Env }}{{ println . }}{{ end }}' \ | grep ^HOME=)" homevar="${homevar#HOME=}" diff --git a/tests/test-basic.sh b/tests/test-basic.sh index 5d5deb1..92894bc 100644 --- a/tests/test-basic.sh +++ b/tests/test-basic.sh @@ -11,7 +11,7 @@ test_basic() { assert_contents /logs/basic.cmd <<'EOF' flatpak list --app --columns=application -podman inspect toolbox-vscode-test --format={{ range .Config.Env }}{{ . }}{{"\n"}}{{ end }} +podman inspect toolbox-vscode-test --format={{ range .Config.Env }}{{ println . }}{{ end }} flatpak ps --columns=instance,application,pid flatpak run com.visualstudio.code --remote attached-container+746f6f6c626f782d7673636f64652d74657374 /home/testuser/project EOF @@ -66,7 +66,7 @@ test_installation() { flatpak list --app --columns=application flatpak remotes --columns=name flatpak install flathub com.visualstudio.code -podman inspect toolbox-vscode-test --format={{ range .Config.Env }}{{ . }}{{"\n"}}{{ end }} +podman inspect toolbox-vscode-test --format={{ range .Config.Env }}{{ println . }}{{ end }} flatpak ps --columns=instance,application,pid flatpak run com.visualstudio.code --remote attached-container+746f6f6c626f782d7673636f64652d74657374 /home/testuser/project EOF @@ -98,7 +98,7 @@ test_running() { assert_contents /logs/running.cmd <<'EOF' flatpak list --app --columns=application -podman inspect toolbox-vscode-test --format={{ range .Config.Env }}{{ . }}{{"\n"}}{{ end }} +podman inspect toolbox-vscode-test --format={{ range .Config.Env }}{{ println . }}{{ end }} flatpak ps --columns=instance,application,pid flatpak enter 123456 sh -c cd $0 From 39e3881d0a782e64d3d2e67a4dae5c1368bfb988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?La=C3=A9rcio=20de=20Sousa?= Date: Mon, 7 Mar 2022 15:03:43 -0300 Subject: [PATCH 6/6] Update code.sh to use new VSCode shell profiles for integrated terminal. --- code.sh | 25 +++++++++++++++---------- tests/test-basic.sh | 25 +++++++++++++++---------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/code.sh b/code.sh index b9d7085..25fc745 100755 --- a/code.sh +++ b/code.sh @@ -383,16 +383,21 @@ if $toolbox_reset_configuration || [ ! -f $settings ] ; then { "remote.containers.copyGitConfig": false, "remote.containers.gitCredentialHelperConfigLocation": "none", - "terminal.integrated.shell.linux": "/usr/sbin/capsh", - "terminal.integrated.shellArgs.linux": [ - "--caps=", - "--", - "-c", - "exec \"\$@\"", - "/bin/sh", - "$SHELL", - "-l" - ] + "terminal.integrated.defaultProfile.linux": "toolbox", + "terminal.integrated.profiles.linux": { + "toolbox": { + "path": "/usr/sbin/capsh", + "args": [ + "--caps=", + "--", + "-c", + "exec \"\$@\"", + "/bin/sh", + "$SHELL", + "-l" + ] + } + } } EOF fi diff --git a/tests/test-basic.sh b/tests/test-basic.sh index 92894bc..905435c 100644 --- a/tests/test-basic.sh +++ b/tests/test-basic.sh @@ -26,16 +26,21 @@ EOF { "remote.containers.copyGitConfig": false, "remote.containers.gitCredentialHelperConfigLocation": "none", - "terminal.integrated.shell.linux": "/usr/sbin/capsh", - "terminal.integrated.shellArgs.linux": [ - "--caps=", - "--", - "-c", - "exec \"$@\"", - "/bin/sh", - "/bin/bash", - "-l" - ] + "terminal.integrated.defaultProfile.linux": "toolbox", + "terminal.integrated.profiles.linux": { + "toolbox": { + "path": "/usr/sbin/capsh", + "args": [ + "--caps=", + "--", + "-c", + "exec \"$@\"", + "/bin/sh", + "/bin/bash", + "-l" + ] + } + } } EOF