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

extension does not work in firefox snap package #86

Closed
carns opened this issue Oct 28, 2021 · 8 comments
Closed

extension does not work in firefox snap package #86

carns opened this issue Oct 28, 2021 · 8 comments

Comments

@carns
Copy link

carns commented Oct 28, 2021

I don't know if this is something that could be fixed in the extension or if it is a fundamental limitation of the snap package system. It's mainly relevant for Ubuntu 21.10 users since Ubuntu elected to change the default Firefox package from apt to snap.

For anyone else who looks at this issue, one workaround is to simply disable the snap package and install the apt one:

snap disable firefox
apt-get install firefox

There are some side effects (in particular: losing bookmarks etc. that you may have created while using the snap package, and of course the issue of whether you want to go against the grain with Ubuntu policy), but this, access to /tmp, and some other extensions will work again.

@Cimbali
Copy link
Owner

Cimbali commented Oct 28, 2021

Thanks for reporting @carns. There’s a lot of things to unpack here I’m afraid:

  • I’m not quite sure what snap is. The doc seems lengthy and lacks a good TL;DR but I’m gathering it’s some sort of security-enhanced packaging system?
  • What do you mean by « does not work »?
    Are no markdown pages rendered at all ? Just file:// URIs? (For example try a gitlab-hosted README.) Or do they render if you open them from the browser but opening from the command line doesn’t redirect to firefox / markdown-viewer?
  • Do any error messages appear in the firefox console ? Something about extensions being disabled, or access to file:// URIs forbidden in these span builds?

@carns
Copy link
Author

carns commented Nov 1, 2021

Unfortunately I am not that familiar with snap either, but Canonical has been transitioning a few packages to that system. From a user perspective two notable things are that packages auto update (rather than prompting you to update) and the packages operate in a file system sandbox so they cannot access all files and directories. There are possibly some other restrictions associated with the sandbox.

As for "does not work", from an end-user perspective, it behaves as if the extension is not present. Firefox prompts to save .md files with an external program.

I'm not sure about error messages in the firefox console; I will have to re-enable the snap version of firefox later and report back.

@Cimbali
Copy link
Owner

Cimbali commented Nov 1, 2021

As for "does not work", from an end-user perspective, it behaves as if the extension is not present. Firefox prompts to save .md files with an external program.

I see. That’s kind of problematic indeed. The usual solutions are to update the list of mime-types in Linux, but that’s something a sandboxed Firefox might not have access to. Though it seems markdown appears in a default system file for me now, in /usr/share/mime/packages/freedesktop.org.xml:

  <mime-type type="text/markdown">
    <comment>Markdown document</comment>
    <comment xml:lang="af">Markdown-dokument</comment>
    <comment xml:lang="ast">Documentu Markdown</comment>
    <comment xml:lang="bg">Документ — Markdown</comment>
    <comment xml:lang="ca">document Markdown</comment>
    <comment xml:lang="cs">dokument Markdown</comment>
    <comment xml:lang="da">Markdown-dokument</comment>
    <comment xml:lang="de">Markdown-Dokument</comment>
    <comment xml:lang="el">Έγγραφο Markdown</comment>
    <comment xml:lang="en-GB">Markdown document</comment>
    <comment xml:lang="es">documento Markdown</comment>
    <comment xml:lang="eu">Markdown dokumentua</comment>
    <comment xml:lang="fi">Markdown-asiakirja</comment>
    <comment xml:lang="fr">document Markdown</comment>
    <comment xml:lang="fur">document Markdown</comment>
    <comment xml:lang="ga">cáipéis Markdown</comment>
    <comment xml:lang="gl">documento de Markdown</comment>
    <comment xml:lang="he">מסמך Markdown</comment>
    <comment xml:lang="hr">Markdown dokument</comment>
    <comment xml:lang="hu">Markdown dokumentum</comment>
    <comment xml:lang="ia">Documento Markdown</comment>
    <comment xml:lang="id">Dokumen markdown</comment>
    <comment xml:lang="it">Documento Markdown</comment>
    <comment xml:lang="ja">Markdown </comment>
    <comment xml:lang="kk">Markdown құжаты</comment>
    <comment xml:lang="ko">마크다운 문서</comment>
    <comment xml:lang="lv">Markdown dokuments</comment>
    <comment xml:lang="nl">Markdown document</comment>
    <comment xml:lang="oc">document Markdown</comment>
    <comment xml:lang="pl">Dokument Markdown</comment>
    <comment xml:lang="pt">documento Markdown</comment>
    <comment xml:lang="pt-BR">Documento Markdown</comment>
    <comment xml:lang="ru">Документ Markdown</comment>
    <comment xml:lang="sk">Dokument Markdown</comment>
    <comment xml:lang="sl">Dokument Markdown</comment>
    <comment xml:lang="sr">Маркдаун документ</comment>
    <comment xml:lang="sv">Markdown-dokument</comment>
    <comment xml:lang="tr">Markdown belgesi</comment>
    <comment xml:lang="uk">документ Markdown</comment>
    <comment xml:lang="zh-CN">Markdown 文档</comment>
    <comment xml:lang="zh-TW">Markdown 文件</comment>
    <sub-class-of type="text/plain"/>
    <glob pattern="*.md"/>
    <glob pattern="*.mkd"/>
    <glob pattern="*.markdown"/>
    <alias type="text/x-markdown"/>
  </mime-type>

@Cimbali
Copy link
Owner

Cimbali commented Nov 8, 2021

I can reproduce so far, with:

  • Ubuntu 21.10
  • snap Firefox
  • local md file

So out of the box, online markdown files like the ones I linked to still work. The proposed action for a local md file is indeed to save as attachment. The workaround currently in the doc of using ~/.mime.types seems to fail for 2 reasons with snap packages:

  1. firefox can’t access files in the home directory
  2. firefox can’t expand the ~ into the home path

Therefore, the workaround is to place the helpers file in a directory accessible by firefox, e.g. where profiles are stored, and to pass the full path. So

  1. create a file in the common data directory for firefox, which is replacing your home directory (i.e. the parent of .mozilla in your profile path). You can see this path from the about:profiles page. For example, my about:profiles says my profile is located at /home/me/snap/firefox/common/.mozilla/firefox/ybmmt15r.default, so I created a file /home/me/snap/firefox/common/mime.types
  2. In this file, write the following line:
    type=text/plain exts=md,mkd,mkdn,mdwn,mdown,markdown, desc="Markdown document"
    
  3. go to about:config and search for helpers.private_mime_types_file
  4. set the value to the path of the file, for me /home/me/snap/firefox/common/mime.types (note that it’s the fully expanded path, not ~/snap/firefox/...)
  5. restart firefox

@Cimbali Cimbali closed this as completed in 2709c7c Nov 8, 2021
@carns
Copy link
Author

carns commented Nov 8, 2021

Thank you for tracking that down @Cimbali !

@Cimbali
Copy link
Owner

Cimbali commented Nov 8, 2021

No worries @carns. This would all be much easier if webextensions could simply define the mime types they handle, but there’s still no ETA on that.

DouglasRoyds pushed a commit to DouglasRoyds/dotfiles that referenced this issue May 24, 2022
Firefox under snap no longer recognises types from the mime database.
We add the mime type to ~/snap/firefox/common/mime.types instead, see
Cimbali/markdown-viewer#86 (comment)

    $ ln -s ~/workspace/dotfiles/firefox/mime.types ~/snap/firefox/common/mime.types
@meonkeys
Copy link

meonkeys commented Jan 19, 2024

Worked for me, except I had to make the filename .mime.types (with a leading period).

Related: I noticed that https://github.com/asciidoctor/asciidoctor-browser-extension somehow works on plain text Asciidoc files without this or other hacks. 🤷

@Cimbali
Copy link
Owner

Cimbali commented Jan 19, 2024

Thanks, I’ll look into how they do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants