wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.75k stars 751 forks source link

Apple Silicon macOS: File permission's don't work all time and with all programs run from wezterm #482

Closed poetaman closed 2 years ago

poetaman commented 3 years ago

Describe the bug

When someone installs a new application on macOS Big Sur, and the application tries to access files in folders like Desktop/Downloads, macOS asks for a permission from user to grant access to the application program. Once granted, the permissions last forever unless user manually removes the permission given to application to access those folders (System Preferences > Security & Privacy > Privacy > Files and Folders > ApplicationName from list > checkboxes). That doesn't seem to be the case for WezTerm, even though right permissions are set & and in place as per information in (System Preferences > Security & Privacy > Privacy > Files and Folders > ApplicationName from list > checkboxes). The same command line programs do not have any problem accessing those files and folders with other terminal emulators like Alacritty, iTerm2, Terminal.app.

Environment:

>> wezterm --version
wezterm 20210203-095643-70a364eb-26-g9bf419eb
>> neofetch
                   'c.           reportaman@Mac-mini.local
                 ,xNMM.          ------------------------------
               .OMMMMo           OS: macOS 11.2 20D64 arm64
               OMMM0,            Host: Macmini9,1
     .;loddo:' loolloddol;.      Kernel: 20.3.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:    
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 1 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: zsh 5.8
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 3840x2160
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Quartz Compositor
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    WM Theme: Blue (Dark)
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal: WezTerm
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   CPU: Apple M1
    kMMMMMMMMMMMMMMMMMMMMMMd     GPU: Apple M1
     ;KMMMMMMMWXXWMMMMMMMk.      Memory: 1909MiB / 16384MiB
       .cooc,.    .,coo:.

To Reproduce

Steps to reproduce the behavior:

  1. Open WezTerm.app for the first time, and try opening some text files in Desktop & Download folders with applications like less or vim. When macOS prompts for permission to allow WezTerm to access files in those folders, grant it.
  2. Check the permissions are correctly set: System Preferences > Security & Privacy > Privacy > Files and Folders > WezTerm > checkboxes for Desktop & Downloads folder. The permissions should be set.
  3. Quit WezTerm.app, and open it again! Try opening files on Desktop/Download folder again using less ~/Desktop/, etc. For some reason, macOS will again ask for permission! This doesn't happen with other terminal applications I have installed on my system.

NOTE-1: The reason I mention that file permission's "don't work all the time" is at times I get this prompt for both Desktop & Downloads folder, and at times just for Desktop (and not for Downloads. i.e. am able to access files right away).

NOTE-2: In my testing I think I saw at times being able to open file from vim using :e ~/Desktop/filename.txt without prompt, but being prompted while trying to open the same file with a vim plugin like Startify or NERDtree. Though can't say defintelty as I am not able to recreate behavior in NOTE-2 at the time of writing this. Also, all this while I did not change any permissions to any file, and did not add/remove files from Desktop/Downloads folder.

Expected behavior

System should not ask for permissions for WezTerm every time it is opened.

Screenshots

Screen Shot 2021-02-12 at 9 51 32 PM

Screen Shot 2021-02-12 at 9 54 17 PM

wez commented 3 years ago

I suspect that this may have something to do with not being code signed. Or alternatively: if you regularly update to nightly, each time the executable is changed it wouldn't surprise me if it needed to be re-granted permissions.

poetaman commented 3 years ago

@wez I have never re-downloaded or updated wezterm, so its not the latter. I have unsigned binaries on my system like Alacritty which came "unsigned" afaik (and seems to be the case from this inflammatory comment from its developer: https://github.com/alacritty/alacritty/issues/1896#issuecomment-690677828), unless I am misunderstanding your reference to "signing".

poetaman commented 3 years ago

@wez Btw, the problem occurs only when WezTerm App is directly opened by clicking the app icon. Opening it by running command (>>wezterm or >>wezterm-gui) from another terminal emulator like inbuilt Terminal, iTerm2, etc doesn't have the same problem (probably because the permissions get chained from the parent terminal emulator application).

wez commented 3 years ago

I can't reproduce this. I wonder if there's something else that we're missing. Where is WezTerm.app installed? is it on a removable device, or installed in /Applications, or somewhere else? How did you install wezterm?

poetaman commented 3 years ago

@wez I had tried this with both prebuilt macOS app, and homebrew's version. And both had caused same problem. Updating them to latest also didn't help.

This worked though:

I already had these WezTerm permissions under System Preferences > Security & Privacy > Privacy > Files & Folders > Wezterm checked, I unchecked them and rechecked them & it magically got resolved.. Its weird this problem never happened with any other application. I guess I had tried before posting the issue, though can't confirm for sure.

Screen Shot 2021-03-19 at 4 37 19 PM
teenjuna commented 3 years ago

I actually encountered the same issue. My environment:

>>> wezterm --version
wezterm 20210503-220535-d64b7852
>>> neofetch
                    'c.          user@macbook.local
                 ,xNMM.          --------------------------
               .OMMMMo           OS: macOS 11.2.3 20D91 arm64
               OMMM0,            Host: MacBookPro17,1
     .;loddo:' loolloddol;.      Kernel: 20.3.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 36 mins
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 1 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: fish 3.1.2
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 1440x900
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Quartz Compositor
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    WM Theme: Blue (Dark)
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal: WezTerm
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   CPU: Apple M1
    kMMMMMMMMMMMMMMMMMMMMMMd     GPU: Apple M1
     ;KMMMMMMMWXXWMMMMMMMk.      Memory: 2190MiB / 16384MiB
       .cooc,.    .,coo:.

Not only I were asked to grant the permissions on every new launch, I were also forced to grant the same permissions like 10 times after calling exa -T in the home directory. There's definitely something wrong. But the solution with rechecking the permissions worked for me too. @reportaman I suggest reopening this.

LuarRaNa commented 2 years ago

Hi !!!

I have the same problem. As @reportaman mentioned this happens with external plug-ins. Like LunarVim in my examples.

Running a command right at HOME trigger the access prompt.

username in ~
❯ lvim ~/.config/wezterm/wezterm.lua
username in ~ took 9s
❯

image

Moving to the specific directory and running the same command works fine.

username in ~/.config/wezterm via 🌙
❯ lvim wezterm.lua
username in ~/.config/wezterm via 🌙 took 6s
❯
kcbark commented 2 years ago

Sorry for posting on a closed issue but the following will probably solve it, it did for me on a mbp m1. It seems to be some kind of code signing issue that triggers this issue.

codesign --force --deep --sign - /Applications/WezTerm.app

LuarRaNa commented 2 years ago

Thanks @kcbark, it works!!

gwww commented 2 years ago

The codesign works for me too! Thx!!!

kyelewis commented 2 years ago

This also happens with other permissions, for me it's microphone access when launching the android-emulator from command line, apple will prompt for microphone access for wezterm on a regular basis while the emulator runs, seems like more than one an hour.

wez commented 2 years ago

I plan to do something to get wezterm codesigned to help with this. Current blockers:

wez commented 2 years ago

OK, the latest nightly is now code signed; hopefully this is the last we see of this issue!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.