Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launchy::ApplicationNotFoundError:

Trying to get save_and_open_page to work at all gives me the following error:

1) index page my first test
 Failure/Error: save_and_open_page
 Launchy::ApplicationNotFoundError:
   No application found to handle 'C:/Sites/Sublist_v2/tmp/capybara/capybara-201304211638563116158687.html'
 # ./spec/features/comics_page_spec.rb:6:in `block (2 levels) in <top (required)>'

Spec:

require 'spec_helper'

feature 'index page' do
  scenario "my first test" do
    visit root_path
    save_and_open_page
    # Launchy.open('http://stackoverflow.com')
  end
end

If I uncomment the Launchy line it works fine, so I'm not sure what the trouble is... maybe a problem with the path c:/?

Gemfile

group :development, :test do
  gem 'spork-rails'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end

group :test do
  gem 'faker'
  gem 'capybara'
  gem 'launchy'
  gem 'database_cleaner'
  gem 'shoulda-matchers'
end
like image 514
tehfailsafe Avatar asked Apr 21 '13 23:04

tehfailsafe


3 Answers

This is because the drive letter in the file path is being incorrectly determined to be part of a uri scheme.

You can temporarily fix it by changing line 12 in /launchy/lib/launchy/applications/browser.rb from:

return true if File.exist?( uri.path ) and uri.scheme.nil?

to

return true if File.exist?( uri.path ) && !schemes.include?( uri.scheme )

like image 90
Brad Werth Avatar answered Nov 15 '22 16:11

Brad Werth


I am the author of Launchy, and was just informed of this issue. I generally do bug fixes via GitHub and have put this issue there. Issue #65

Any time you encounter an issue with Launchy, please turn on launchy debugging and file an issue with the project on github

You can can turn on launchy debugging by setting the environment variable LAUNCHY_DEBUG=true. You can do this either from the shell, or via ruby code if you are embedding launchy in your application.

% export LAUNCHY_DEBUG=true
% launchy http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror
AUNCHY_DEBUG: URI parsing pass 1 : http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror -> {:scheme=>"http", :user=>nil, :password=>nil, :host=>"stackoverflow.com", :port=>nil, :path=>"/questions/16137410/launchyapplicationnotfounderror", :query=>nil, :fragment=>nil}
LAUNCHY_DEBUG: Checking if class Launchy::Application::Browser is the one for handles?(http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
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?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)}
LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : possibility : /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : Using browser value '/usr/bin/open'
LAUNCHY_DEBUG: wet_run: before exec in child process
LAUNCHY_DEBUG: commandline_normalized => /usr/bin/open http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror

Or if you are embedding launchy:

% irb
>> require 'launchy'
>> ENV['LAUNCHY_DEBUG']="true"
>> Launchy.open( "http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror" )
LAUNCHY_DEBUG: URI parsing pass 1 : http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror -> {:scheme=>"http", :user=>nil, :password=>nil, :host=>"stackoverflow.com", :port=>nil, :path=>"/questions/16137410/launchyapplicationnotfounderror", :query=>nil, :fragment=>nil}
LAUNCHY_DEBUG: Checking if class Launchy::Application::Browser is the one for handles?(http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
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?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)}
LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : possibility : /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : Using browser value '/usr/bin/open'
LAUNCHY_DEBUG: wet_run: before exec in child process
>> LAUNCHY_DEBUG: commandline_normalized => /usr/bin/open http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror
like image 28
copiousfreetime Avatar answered Nov 15 '22 15:11

copiousfreetime


I just had to do:

fileUri = 'file:///' + outputFile.path

Launchy.open(fileUri)

note the three slashes after "file:". This is with github-markdown-0.5.5 on Windows 8.

like image 29
gerrard00 Avatar answered Nov 15 '22 15:11

gerrard00