Skip to content
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

.dart files are treated as disk images (security sensitive) on Macs #28205

Open
eseidelGoogle opened this issue Dec 27, 2016 · 16 comments
Open
Labels
area-documentation Prefer using 'type-documentation' and a specific area label.

Comments

@eseidelGoogle
Copy link

This is not Dart's "fault" per say, but it isn't going to help us reach less-terminal-friendly Mac developers and may be something we need to call out in our getting started docs, or work around in some way?

Dart files show up like this in the finder:
screen shot 2016-12-27 at 12 11 40 pm

If you try and double click ones you've downloaded, you will get this:
screen shot 2016-12-27 at 12 14 39 pm

Even if you use "Open With...":
screen shot 2016-12-27 at 12 13 19 pm

And configure the default handler:
screen shot 2016-12-27 at 12 13 44 pm

You will still get that security dialog for downloaded .dart files. I don't currently know of a workaround.

@matanlurey
Copy link
Contributor

/sub

@sethladd
Copy link
Contributor

What should happen when I double click the file?

@eseidelGoogle
Copy link
Author

eseidelGoogle commented Dec 27, 2016

Ideally we would instruct users how to bind .dart files how to open in their favorite editor (without warnings). Try downloading a .txt file from the internet and double clicking it, e.g.:
option-click on "Raw" (to download) in https://github.com/flutter/flutter/blob/master/README.md and then double click it (it will open in XCode by default w/o any security warnings).
Now try a .dart file to see the above. :)

Well, it's possible to bind certain extensions to certain apps on Mac:
https://developer.apple.com/library/content/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html#//apple_ref/doc/uid/TP30000999-CH202-BABEJFCD

Apps can sign up to support certain types with their Info.plist files:
https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html

I guess none of the apps on my system are signed up for .dart (but I expect that to be common). .dart also seems to have some special security treatment (at least by default? not sure if that's changeable), given that it can be a disk image and thus contain executable code.

@mit-mit
Copy link
Member

mit-mit commented Dec 28, 2016

I think the issue here is that .dart / com.apple.disk-image-dart is a registered MacOS file format:
https://support.apple.com/kb/TA29157?locale=en_US&viewlocale=en_US

@anders-sandholm anders-sandholm added the area-documentation Prefer using 'type-documentation' and a specific area label. label Jan 3, 2017
@anders-sandholm
Copy link
Contributor

Added documentation label for now.
We should at least talk about this - even if there is no work-around given the overlap with MacOS' DART (Disk Archive/Retrieval Tool).

@kwalrath
Copy link
Contributor

kwalrath commented Jan 3, 2017

I guess I could talk about this in the Mac installation page, which is the only Mac-specific page I can think of. But a real fix or good workaround would be better, of course.

@gspencergoog
Copy link
Contributor

Maybe we can write a small app that registers for the .dart extension and simply visually enumerates the text editor and "Other..." apps on the system to ask which executable .dart should be associated with, and then registers that app to handle it going forward. Then we can just suggest that people install it to solve this problem (and we can install it with the Dart SDK on OSX).

[IANAAD (I Am Not An Apple Developer), so it's possible there are security blockades to that approach too, of course.]

@cseder
Copy link

cseder commented Nov 14, 2018

Would be nice to find a simple solution to this.

What I did to work around this was first choosing to open all .dart files with Sublime Text, by cmd + i on a .dart file and choose Open With... Select Sublime Text and click "Change all".

I then created a DART.icns file to use for .dart files in Finder and added it into the Sublime Text app bundle Resources folder (/Applications/Sublime Text.app/Contents/Resources).

resources.png

and edited the /Applications/Sublime Text.app/Contents/Info.plist to contain an entry for Dart files:

info-plist.png

The applications listed in the Launch Services database on MacOS uses the info from the Info.plist for each application in /Applications, so after choosing Sublime Text as the default application for all .dart files and adding the .icns file and the appropriate entry in Info.plist and rebuilding the Launch Services database, Finder handles the files the way I want, showing the icon I added to the Sublime resources and promptly opens the file in Sublime Text upon double-clicking it.

Rebuilding the LaunchService database can be done by running a command in a Terminal:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

After a reboot, it looks all good:

finder.png

Opening in Sublime Text shows the icon from resources in the application bar as well! :)

sublime.png

This is definitely a cumbersome workaround, but it can probably be customized for any code editor using the same steps...

@osaxma
Copy link
Contributor

osaxma commented Feb 26, 2019

Another way to fix it (without dart icon):

  • Right Click on any .dart file
  • Click Get Info
  • Choose your favorite editor
  • Then click Change All
    screen shot 2019-02-25 at 11 43 42 pm

To enable the QuickLook, I installed a QuickLook Plugin called qlstephen:
brew cask install qlstephen
then restart QuickLook
qlmanage -r

@eseidelGoogle
Copy link
Author

It seems silly that we still have this bug in 2019.

Is it possible to at least add .dart as a known type to VSCode or IntelliJ (via the Flutter or Dart plugins) so these show up correctly when a user has those installed? @DanTup @devoncarew @mit-mit @csells

@DanTup
Copy link
Collaborator

DanTup commented Feb 27, 2019

@eseidelGoogle I'm not sure, I've opened microsoft/vscode#69551 asking. VS Code supports associating itself with files during install, and also can give them icons. It's not clear if it's reserved for things shipped with out-of-the-box support though.

@leapit
Copy link

leapit commented Mar 2, 2019

trouble with this too

@DanTup
Copy link
Collaborator

DanTup commented Mar 4, 2019

VS Code doesn't want to do this at install time because Dart isn't a built-in language, so if we wanted to do something, it'd have to be done ourselves. I'm not sure how complicated that'd be (we'd need to do it for each OS).

@eseidelGoogle
Copy link
Author

I linked to some docs back in #28205 (comment). Last I was aware, file extensions couldn't be added separately from app install, but maybe that's changed?

@DanTup
Copy link
Collaborator

DanTup commented Mar 4, 2019

Last I was aware, file extensions couldn't be added separately from app install, but maybe that's changed?

I ran this:

defaults write com.apple.LaunchServices LSHandlers -array-add \
"<dict><key>LSHandlerContentTag</key>
<string>dart</string><key>LSHandlerContentTagClass</key>
<string>public.filename-extension</string><key>LSHandlerRoleAll</key>
<string>com.microsoft.vscode</string></dict>"

And rebooted, and now my .dart files open with VS Code. However, they still have the original icon. I'm not sure how to fix that.. I did some searching, but the internet suggests that this may have to be done in the app (the app that will be opened supplies the icon?) in which case, we may be stuck.

@Panway
Copy link

Panway commented Dec 15, 2019

I found a solution that can preview dart files on MacOS: https://medium.com/@claudmarotta/how-to-preview-dart-files-with-macos-quick-look-54779340811f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-documentation Prefer using 'type-documentation' and a specific area label.
Projects
None yet
Development

No branches or pull requests