microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.38k stars 28.61k forks source link

NameError: name 'code' is not defined. #172124

Closed SebastianSosa closed 9 months ago

SebastianSosa commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. cmd code --log trace
  2. in vscode terminal :
  3. conda
  4. node
  5. Python
  6. docker
  7. return NameError: name 'code' is not defined.

Windows path: image

In the developer tools, the process.env.path returns: 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\rtools40\qpdf-10.3.2\bin;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.3.0\;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\rtools40\qpdf-10.3.2\bin;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.3.0\;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin;C:\Users\SSosa\AppData\Local\Programs\Microsoft VS Code\bin;'

Unable to include log file due to word count restrictions

Thanks

bwateratmsft commented 1 year ago

We've seen some other issues in the AZD extension that might be the same root cause: https://github.com/Azure/azure-dev/issues/1441

It seems like at some point in the chain, the PATH environment variable is not propagating from VSCode's primary process, to the extension host processes, to the processes (attempted to be) launched by the extension.

Tyriar commented 1 year ago

It's not clear where the issue occurs exactly, it reads like you're running docker inside python, inside node, inside conda? Can you provide simpler steps?

bwateratmsft commented 1 year ago

@Tyriar I think the user means running any of those. This issue might also be the same: https://github.com/microsoft/vscode-docker/issues/3811

SebastianSosa commented 1 year ago

Indeed none of these codes are working.

SebastianSosa commented 1 year ago

Here is my log output: [https://1drv.ms/t/s!AoQDo4rhPD_ymI429icbYgUttXWEew?e=I11keR] (url)

Another potentially useful information is how I am currently able to run Python scripts on VS Code. If I create a new file, I am unable to run the Python script and receive an error message 'python' is not defined. However, if I change the interpreter to 'conda base' then I am able to run it.

SebastianSosa commented 1 year ago

Here are my .json settings

    {
    "security.workspace.trust.untrustedFiles": "open",
    "liveServer.settings.donotShowInfoMsg": true,
    "explorer.confirmDelete": false,
    "explorer.confirmDragAndDrop": false,
    "liveServer.settings.donotVerifyTags": true,
    "tabnine.experimentalAutoImports": true,
    "indentRainbow.lightIndicatorStyleLineWidth": 10,
    "notebook.output.textLineLimit": 1000,
    "terminal.integrated.env.windows": {
    "PATH": ""
    },
    "terminal.integrated.defaultProfile.windows": "Windows PowerShell",
    "editor.tabCompletion": "on",
    "python.analysis.autoImportCompletions": true,
    "python.analysis.completeFunctionParens": true,
    "notebook.cellToolbarLocation": {
    "default": "right",
    "jupyter-notebook": "right"
    },
    "docker.commands.attach": "${containerCommand} exec -it ${containerId} ${shellCommand}",
    "python.defaultInterpreterPath": "C:\\Users\\SSosa\\anaconda3\\python.exe",
    "code-runner.executorMap": {

    "javascript": "node",
    "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "zig": "zig run",
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "php": "php",
    "python": "python -u",
    "perl": "perl",
    "perl6": "perl6",
    "ruby": "ruby",
    "go": "go run",
    "lua": "lua",
    "groovy": "groovy",
    "powershell": "powershell -ExecutionPolicy ByPass -File",
    "bat": "cmd /c",
    "shellscript": "bash",
    "fsharp": "fsi",
    "csharp": "scriptcs",
    "vbscript": "cscript //Nologo",
    "typescript": "ts-node",
    "coffeescript": "coffee",
    "scala": "scala",
    "swift": "swift",
    "julia": "julia",
    "crystal": "crystal",
    "ocaml": "ocaml",
    "r": "Rscript",
    "applescript": "osascript",
    "clojure": "lein exec",
    "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
    "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
    "racket": "racket",
    "scheme": "csi -script",
    "ahk": "autohotkey",
    "autoit": "autoit3",
    "dart": "dart",
    "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
    "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
    "haskell": "runghc",
    "nim": "nim compile --verbosity:0 --hints:off --run",
    "lisp": "sbcl --script",
    "kit": "kitc --run",
    "v": "v run",
    "sass": "sass --style expanded",
    "scss": "scss --style expanded",
    "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
    "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "sml": "cd $dir && sml $fileName"
},
"terminal.integrated.profiles.windows": {
    "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell"
    },
    "Command Prompt": {
        "path": [
            "${env:windir}\\Sysnative\\cmd.exe",
            "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": "Git Bash"
    },
    "Ubuntu-22.04 (WSL)": {
        "path": "C:\\Windows\\System32\\wsl.exe",
        "args": [
            "-d",
            "Ubuntu-22.04"
        ]
    },
    "Windows PowerShell": {
        "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    }
},
"editor.codeActionsOnSave": {

}

}

meganrogge commented 9 months ago

/duplicate #118460