Skip to content

VSCode terminal doesn't allow/request permissions to access media devices #95062

Closed

Description

  • VSCode Version: 1.44.0
  • OS Version: Max OSX Catalina 10.15.2

Steps to Reproduce:

  1. Run this python script in the VSCode terminal which needs access to the camera:
import cv2

cam = cv2.VideoCapture(0)
print(cam.isOpened())
cam.release()

The result will be Abort trap: 6. This also occurs if you try to run the debugger.
The script does work in the Mac Terminal and iTerm.

This is likely because vscode does not have permissions to access the camera. There is no way to force vscode to appear in the Mac permissions (Security & Privacy -> Privacy -> Camera), such that it cannot be enabled by the user.

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

Activity

  1. vscodebot commented on Apr 12, 2020

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. jvanheugten commented on Apr 12, 2020

    @jvanheugten
    Author

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

    Probably both issues have similar origin, namely camera permissions are not set for vscode.

  3. deepak1556 commented on Apr 13, 2020

    @deepak1556
    Collaborator

    Jasper van Heugten, PhD (@jvanheugten) your assumption is correct. But if your macOS terminal app got the permissions to access camera, then any process spawned from it should get that. I am unable to reproduce the crash with the terminal from inside code after I grant the terminal access to camera.

    Can you share a video demo ?

  4. jvanheugten commented on Apr 14, 2020

    @jvanheugten
    Author

    image
    Here is a simple demonstration. Mac OS Terminal shows the correct result, but terminal in VSCode does not.

    Does VSCode spawn a emulated terminal? If MacOS thinks it is VSCode that spawns it, I would expect a permission request to access the camera, but that never happens. My privacy settings do show that Terminal has access to the camera, but there is no way to add VSCode to that list.

  5. deepak1556 commented on Apr 14, 2020

    @deepak1556
    Collaborator

    Have your restarted code after giving your macOS terminal access to camera ? Otherwise code wouldn't pick up the privilege for the terminals it opens.

    Does VSCode spawn a emulated terminal?

    Daniel Imms (@Tyriar) how do we spawn terminals on macOS ?

    I tried the following steps and it seems to work , https://streamable.com/zsa8ro

    My privacy settings do show that Terminal has access to the camera, but there is no way to add VSCode to that list.

    Yes you can't do that at the moment, because code doesn't carry the entitlement that requests access to camera. I am looking to avoid adding this unless necessary, but for the current use case through the terminal things should work the way it is.

  6. jvanheugten commented on Apr 14, 2020

    @jvanheugten
    Author

    Yes, I've restarted vscode a couple of times. I'll try uninstalling and reinstalling it from scratch tomorrow.

  7. jvanheugten commented on Apr 15, 2020

    @jvanheugten
    Author

    I just completely uninstalled VSCode and re-installed it and restarted my computer. The problem is still there.

    I even deleted everything according to similar paths here: https://stackoverflow.com/questions/42603103/how-to-completely-uninstall-vscode-on-mac

  8. jvanheugten commented on Apr 15, 2020

    @jvanheugten
    Author

    Just ran VSCode as administrator:
    sudo /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron
    Then my terminal in VSCode will run as root and the program executes as normal.

    Of course, that is not a real solution though, but it shows some permissions are not handled correctly.

  9. deepak1556 commented on Apr 15, 2020

    @deepak1556
    Collaborator

    Thanks for the context, based on #95062 (comment) since we execvp, macOS tcc utility will consider the permissions of the parent process instead of the forked process.

    But I am still confused why it wasn't an issue with my setup, moving this next milestone for further investigation.

  10. 44 remaining items

  11. adgbu commented on Mar 12, 2021

    @adgbu

    mattialibera No, I used the tccutil tool.
    I got it working now, by using the SQL INSERT commands directly.
    A couple of things that may help someone else:

    1. There is a typo in your SQL command for Catalina where is says "com.microsoft.VSCoda".
    2. My biggest problem was that I could not read the TCC.db file or even list that directory until after I booted into Recovery mode and turned off SIP. What I really should have done was to turn on Full disk access for Terminal, but I didn't know that.

    Thanks for taking the time to answer.

  12. HoBu23 commented on Mar 13, 2021

    @HoBu23

    macOS Big Sur, version 11.2.3.

    I have written a script in Python3 for speech recognition. When I run this script in VSCode internal terminal, I can't pick up any signal from the microphone. Then I tried to run my script natively in MAC terminal, it works after accepting the permission for microphone.
    I tried again in VSCode internal terminal and same problem as before. No signal from the microphone.
    I miss the permission for microphone in the VSCode terminal.

    I tried out the way by Wolf Rogner (@wrogner) with no success at first.
    Then i found Comment: #95062 (comment)
    """
    Also, before running the above comments, you need to grant Full Disk Access to Terminal.
    You can do so at: System Preferences -> Security & Privacy -> Privacy tab -> Full Disk Access row in left sidebar
    """
    That was the key. Now i can get data from microphon in VSCode.

    Thanks Wolf Rogner (@wrogner) and Samagra Singh Tomar (@sst2010)

  13. wrogner commented on Mar 13, 2021

    @wrogner

    Horst Buttkau (@HoBu23) : Please read the suggested solutions (and verify them) before submitting an addition.
    Solutions for > 10.15.x by Wolf Rogner (@wrogner)
    Solutions for < 10.15.x by mattialibera

  14. HoBu23 commented on Mar 13, 2021

    @HoBu23

    Horst Buttkau (@HoBu23) : Please read the suggested solutions (and verify them) before submitting an addition.
    Solutions for > 10.15.x by Wolf Rogner (@wrogner)
    Solutions for < 10.15.x by mattialibera

    okay, thanks for your info, but I have no success with Wolf Rogner (@wrogner) way. Problem with open .db in sqlite3. But with comment from Samagra Singh Tomar (@sst2010) it works.

    Now I tried it in IntelliJ IDEA.

    This is the result:
    IntelliJ IDEA

    I think Microsoft should still think about this

  15. added
    unreleasedPatch has not yet been released in VS Code Insiders
    insiders-releasedPatch has been released in VS Code Insiders
    and removed
    unreleasedPatch has not yet been released in VS Code Insiders
    on Mar 31, 2021
  16. vscode-triage-bot commented on Apr 29, 2021

    @vscode-triage-bot

    This bug has been fixed in the latest release of VS Code Insiders!

    Jasper van Heugten, PhD (@jvanheugten), you can help us out by commenting /verified if things are now working as expected.

    If things still don't seem right, please ensure you're on version 0123d26 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

    Happy Coding!

  17. locked and limited conversation to collaborators on May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugconfirmedIssue has been confirmed by VS Code Team memberinsiders-releasedPatch has been released in VS Code Insidersmacos-catalinaterminalGeneral terminal issues that don't fall under another labelverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions