markbates / cover_me

An RCov-esque coverage tool for Ruby 1.9
http://www.metabates.com
MIT License
204 stars 18 forks source link

cover_me: calls wrong command open (probably mean xdg-open?) #45

Open edwintorok opened 13 years ago

edwintorok commented 13 years ago

Ever since cover_me got added to Gemfile on every rake command I invoke I see this: Couldn't get a file descriptor referring to the console

And if logged on the console I get access denied to /dev/tty7

strace shows cover_me tries to do this: [pid 4722] execve("/bin/open", ["open", "...site/coverage/index.html"], [/* 18 vars */]) = 0

cover_me has this code: c.set_default(:at_exit, Proc.new { if CoverMe.config.formatter == CoverMe::HtmlFormatter index = File.join(CoverMe.config.html_formatter.output_path, 'index.html') if File.exists?(index) open #{index}

I don't know under what OS "open index.html" opens the file in your browser, but on Linux open does something completely different: lrwxrwxrwx 1 root root 6 Feb 1 21:12 /bin/open -> openvt

DESCRIPTION openvt will find the first available VT, and run on it the given command with the given command options, standard input, output and error are directed to that terminal. The current search path ($PATH) is used to find the requested command. If no command is specified then the environment variable $SHELL is used.

What you are looking for probably is xdg-open:

DESCRIPTION xdg-open opens a file or URL in the user's preferred application. If a URL is provided the URL will be opened in the user's preferred web browser. If a file is provided the file will be opened in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs.

If xdg-open is installed that is...

dicom commented 13 years ago

This crashes on windows as well, where the equivalent command to 'open' is 'start'.

Seems to me there needs to be a platform detection in the code in order to select the appropriate command to launch this document.