nix-env-selector icon indicating copy to clipboard operation
nix-env-selector copied to clipboard

Add logging to VS Code output channel

Open daneads opened this issue 2 years ago • 2 comments

  • Create a VS Code output channel during init
  • Log basic operations and error messages
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:

  • Load config
  • Select/hit env
  • Run a sync/async command

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.

daneads avatar Nov 21 '21 12:11 daneads

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

arrterian avatar Nov 25 '21 12:11 arrterian

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

khumps avatar Apr 19 '22 08:04 khumps

would be good to have this merged

maurerbot avatar Oct 20 '22 23:10 maurerbot

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

steshaw avatar Nov 23 '22 08:11 steshaw

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

manupadillaph avatar May 12 '23 23:05 manupadillaph