arrterian / nix-env-selector

Allows switch environment for Visual Studio Code using Nix Package Manager.
MIT License
220 stars 29 forks source link

Add logging to VS Code output channel #64

Closed daneads closed 7 months ago

daneads commented 2 years ago
Status Type Config Change
Ready Feature No

Problem

As mentioned in #59 , it would be useful to have the extension log to the Output window, for example to help troubleshoot Nix errors.

Solution

This creates a VS Code Output Channel during init, to which log messages can be appended.

I add logs for these operations:

Example output in the Nix Env Selector channel, including the error referenced in #59:

Initializing config...
Loaded config: {:workspace-root "/home/dan/test_nix_env", :nix-file "/home/dan/test_nix_env/env.nix", :suggest-nix? false, :nix-packages #js [], :nix-args nil, :nix-shell-path "/nix/store/hapw7q1fkjxvprnkcgw9ppczavg4daj2-nix-2.4/bin/nix-shell"}
Running command synchronously: /nix/store/hapw7q1fkjxvprnkcgw9ppczavg4daj2-nix-2.4/bin/nix-shell "/home/dan/test_nix_env/env.nix" --run export
Error applying environment: Error: Command failed: /nix/store/hapw7q1fkjxvprnkcgw9ppczavg4daj2-nix-2.4/bin/nix-shell "/home/dan/test_nix_env/env.nix" --run export
error: attribute 'npm' missing

       at /home/dan/test_nix_env/env.nix:5:9:

            4|     buildInputs = [
            5|         pkgs.npm
             |         ^
            6|     ];
(use '--show-trace' to show detailed location information)

Running action: Select environment
Running action: Hit environment
Selected to disable Nix environment
Selected Nix file: /home/dan/test_nix_env/env.nix
Loading env in path: /home/dan/test_nix_env/env.nix
Running command asynchronously: /nix/store/hapw7q1fkjxvprnkcgw9ppczavg4daj2-nix-2.4/bin/nix-shell "/home/dan/test_nix_env/env.nix" --run export
Error applying environment: error: attribute 'npm' missing

       at /home/dan/test_nix_env/env.nix:5:9:

            4|     buildInputs = [
            5|         pkgs.npm
             |         ^
            6|     ];
(use '--show-trace' to show detailed location information)

Other changes (e.g. bug fixes, UI tweaks, small refactors)

Deploy Notes

No new dependencies or scripts.

arrterian commented 2 years ago

@daneads Thank you for your contribution a lot. I leave a comment about your changes.

khumps commented 2 years ago

Was this abandoned? This was my immediate thought for an issue to open once I started using this extension and it appears to be stalled

maurerbot commented 1 year ago

would be good to have this merged

steshaw commented 1 year ago

Is there another way to debug a spinning "Applying environment..."?

manupadillaph commented 1 year ago

hello! still wainting for this The extension es awesome, but when there are errors, is very hard to debug