-
Notifications
You must be signed in to change notification settings - Fork 29.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VSCode terminal doesn't allow/request permissions to access media devices #95062
Comments
(Experimental duplicate detection) |
Probably both issues have similar origin, namely camera permissions are not set for vscode. |
@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 ? |
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.
@Tyriar how do we spawn terminals on macOS ? I tried the following steps and it seems to work , https://streamable.com/zsa8ro
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. |
Yes, I've restarted vscode a couple of times. I'll try uninstalling and reinstalling it from scratch tomorrow. |
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 |
Just ran VSCode as administrator: Of course, that is not a real solution though, but it shows some permissions are not handled correctly. |
Thanks for the context, based on #95062 (comment) since we But I am still confused why it wasn't an issue with my setup, moving this next milestone for further investigation. |
Similar issue exists with access to the microphone via Pythoh. In both cases it seems that the VSCode terminal is not requesting permissions from MacOS. I say this because if you run the same CLI command via the built-in MacOS Terminal app then permissions are requested and everything works as it should. Proposed solution: update VSCode terminal to request permissions from MacOS. |
@jelling thanks for the report. the root cause is same. I have updated the bug title. |
I tried all those step but doesn't working |
I am having the same issue the python code runs without issue from terminal which is able to request the appropriate permissions. VSCode however does not request permissions as expected. The line |
@csarami my solution doesn't mention those attributes; below the screenshot: |
The table structure in Mojave is different to BigSur. With your qualifications you should be able to figure out the attributes. |
First of all, there is no need to be in the recovery mode to edit the database but terminal app needs full disk access. Mojave version is here, at your own risk. Be careful.
|
Thanks @Naohiro2g ! Worked for me on Big Sur 11.3 Beta after adding another value and restarting VSCode. For the Insider version, just use "com.microsoft.VSCodeInsiders". VALUES('kTCCServiceCamera',"com.microsoft.VSCode",0,1,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109); |
ph1q, thanks for the info regarding BigSur and insiders. We'd better to wait for the bug fix release but you can try the solution at your own risk. BE CAREFUL, IT'S DANGEROUS ENOUGH TO EDIT THE DATABASE BY HAND.You Have Been Warned.Check if 'Full Disk Access' is granted to the terminal app you are using inside VS Code.
cd ~/Library/Application\ Support/com.apple.TCC/
cp TCC.db TCC.db.bak
sqlite3 TCC.db # sqlite> prompt appears. for Mojave, Catalina
INSERT into access VALUES('kTCCServiceCamera',"com.microsoft.VSCode",0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);
for BigSur
INSERT into access VALUES('kTCCServiceCamera',"com.microsoft.VSCode",0,1,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);
for Microphone, replace the keyword with
'kTCCServiceMicrophone'
for VS Code Insiders, go with
'com.microsoft.VSCodeInsiders' |
Thanks, @wrogner for this useful solution !! |
I code with vscode but run the code with iTerm. Its work for me |
@GusnaIkhsan You launch VS Code via If you have VS Code open all the time, and are used to using the terminal in VS Code, you may find it a bit cumbersome to restart VS Code using the terminal outside. And you need to grant full disk access permission to the terminal app beforehand, like in another workaround. |
Using the webcam (and virtual webcams) with Python+OpenCV from Terminal works fine. I can not get it to work within VSCode no matter what I do. I have tried to grant permission to VSCode through the TCC but it still won't work. Don't know if I did it right. I used this tool tccutil by jacobsalmela. I also had to reboot into Recovery mode and disable SIP before I could try this. I got the util to work, but still no camera access inside VSCode. I was thinking whether it would be possible to write a VSCode extension that just opens the camera and the microphone and does so by the book according to Apple's API recommendation. Would that bring up the dialog to grant permission to these resources for VSCode? |
On MacOS sometimes OpenCV has some communication problems with some webcams; I'm almost sure that the problem is about that and not related with vscode in this case. |
@mattialibera |
@adgbu did you use exactly commands in my/others posts above? Which OS version do you have? |
@mattialibera No, I used the tccutil tool.
Thanks for taking the time to answer. |
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 out the way by @wrogner with no success at first. |
@HoBu23 : Please read the suggested solutions (and verify them) before submitting an addition. |
okay, thanks for your info, but I have no success with @wrogner way. Problem with open .db in sqlite3. But with comment from @sst2010 it works. Now I tried it in IntelliJ IDEA. I think Microsoft should still think about this |
Steps to Reproduce:
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
The text was updated successfully, but these errors were encountered: