ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.73k stars 238 forks source link

version 1.5.0 doesn't work #148

Closed alpemaca closed 6 years ago

alpemaca commented 6 years ago

Hi, not sure if I have something wrong, but I had no problems with lower versions of the gem in other projects.

The email isn't shown in the browser, instead, an error message appears in the logs:

Error showing URL: Operation not supported

I'm using Rails 5.1.4 and Ruby 2.5.0

I'm viewing the code and the problem (if any) seems to be inside lib/letter_opener/delivery_method.rb, in the line:

Launchy.open("file:///#{URI.parse(CGI.escape(messages.first.filepath))}")

if I use URI.escape or CGI.parse it fixes the problem but I don't know if it implies other problems.

Thanks very much!

nashby commented 6 years ago

@alpemaca hey, what OS are you using?

nashby commented 6 years ago

@alpemaca could you please also show full path to your project?

alpemaca commented 6 years ago

@nashby

I'm using linux mint 17.2 which is based on ubuntu 14.04.

Path: /home/alberto/dev/newproject/

nashby commented 6 years ago

@alpemaca I see. Could you please run your Rails server with LAUNCHY_DEBUG=true so we can check logs from Launchy?

alpemaca commented 6 years ago

Here it is, thanks :)

LAUNCHY_DEBUG: URI parsing pass 1 : file:///%2Fhome%2Falberto%2Fdev%2Fnewproject%2Ftmp%2Fletter_opener%2F1514928144_2240384_c494910%2Frich.html -> {:scheme=>"file", :user=>nil, :password=>nil, :host=>"", :port=>nil, :path=>"/%2Fhome%2Falberto%2Fdev%2Fnewproject%2Ftmp%2Fletter_opener%2F1514928144_2240384_c494910%2Frich.html", :query=>nil, :fragment=>nil} LAUNCHY_DEBUG: Checking if class Launchy::Application::Browser is the one for handles?(file:///%2Fhome%2Falberto%2Fdev%2Fnewproject%2Ftmp%2Fletter_opener%2F1514928144_2240384_c494910%2Frich.html)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(linux-gnu)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(linux-gnu)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Nix is the one for matches?(linux-gnu)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(linux-gnu)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(linux-gnu)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Nix is the one for matches?(linux-gnu)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)} LAUNCHY_DEBUG: Checking if class Launchy::Detect::NixDesktopEnvironment::Kde is the one for is_current_desktop_environment?()} LAUNCHY_DEBUG: Checking if class Launchy::Detect::NixDesktopEnvironment::Gnome is the one for is_current_desktop_environment?()} LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/gnome-open LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/gnome-open LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/firefox LAUNCHY_DEBUG: Launchy::Application : Unable to find 'iceweasel' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : Unable to find 'seamonkey' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/opera LAUNCHY_DEBUG: Launchy::Application : Unable to find 'mozilla' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : Unable to find 'netscape' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : Unable to find 'galeon' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application::Browser : possibility from app_list : gnome-open LAUNCHY_DEBUG: Launchy::Application::Browser : possibility from app_list : firefox LAUNCHY_DEBUG: Launchy::Application::Browser : possibility from app_list : opera LAUNCHY_DEBUG: Checking if class Launchy::Detect::NixDesktopEnvironment::Kde is the one for is_current_desktop_environment?()} LAUNCHY_DEBUG: Checking if class Launchy::Detect::NixDesktopEnvironment::Gnome is the one for is_current_desktop_environment?()} LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/gnome-open LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/gnome-open LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/firefox LAUNCHY_DEBUG: Launchy::Application : Unable to find 'iceweasel' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : Unable to find 'seamonkey' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/opera LAUNCHY_DEBUG: Launchy::Application : Unable to find 'mozilla' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : Unable to find 'netscape' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application : Unable to find 'galeon' in /home/alberto/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bin, /home/alberto/.rbenv/versions/2.5.0/bin, /home/alberto/.rbenv/libexec, /home/alberto/.rbenv/plugins/ruby-build/bin, /home/alberto/.pyenv/plugins/pyenv-virtualenv/shims, /home/alberto/.pyenv/shims, ~/.pyenv/bin, /home/alberto/.nvm/versions/node/v6.10.3/bin, /usr/local/heroku/bin, /home/alberto/.rbenv/shims, /opt/android-sdk/build-tools/, /usr/share/elasticsearch/bin, /home/alberto/.rbenv/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /opt/android-sdk/tools, /opt/android-sdk/platform-tools, /opt/node/bin, /opt/gradle/bin LAUNCHY_DEBUG: Launchy::Application::Browser : Using browser value 'gnome-open' LAUNCHY_DEBUG: wet_run: before exec in child process LAUNCHY_DEBUG: commandline_normalized => gnome-open file:///%2Fhome%2Falberto%2Fdev%2Fnewproject%2Ftmp%2Fletter_opener%2F1514928144_2240384_c494910%2Frich.html

nashby commented 6 years ago

@alpemaca thanks! As I can see Launchy gem already uses Addressable to parse url we pass to it so I think we don't really need to escape anything more. Could you please try change that line to Launchy.open("file:///#{messages.first.filepath}") and see if that works?

alpemaca commented 6 years ago

@nashby

Yes, it works

nashby commented 6 years ago

@alpemaca thanks! I pushed a fix to master branch. Feel free to use it.

alpemaca commented 6 years ago

@nashby Thanks very much for your job :)

redtachyons commented 6 years ago

Facing the same issue, early release will be appreciated

nashby commented 6 years ago

New version is released.