yaauie / cliver Goto Github PK
View Code? Open in Web Editor NEWA ruby gem that provides tools for detecting & verifying command-line dependencies
Home Page: http://yaauie.github.io/cliver/
License: MIT License
A ruby gem that provides tools for detecting & verifying command-line dependencies
Home Page: http://yaauie.github.io/cliver/
License: MIT License
The current method of supplying version-detection is somewhat cumbersome with its Regexp
s and capture groups. Make it less sucky.
Current thoughts:
#to_proc
, with argument of the executable name, and return a string, dot-separated version number.Since the current version matcher pattern prettymuch matches numbers in general, let's favor things that match more of the cues (e.g., if it is prefixed with version, or is composed of several parts that are dot-separated).
Please feel free to supply STDOUT and STDERR for your app's --version
output, along with the expected match version so I can add tests to ensure.
Could not find an executable at given path 'C:/Program Files (x86)/phantomjs-1.9.8-windows/phantomjs.EXE'.If this path was not specified explicitly, it is probably a bug in Cliver.
im investigating changing the extension of the phantomjs as a workaround.
ill tell you if this works.
Using Go, installed at C:\Program Files (x86)\Go Agent..., when I put the binary for PhantomJS in the working folder (C:\Program Files (x86)\Go Agent\pipelines\my_project...) clover can not properly deduce the version.
Escaping the spaces on the path doesn't help. When I quote the executable_path then I wind up with an EACCES error. I've been unable to patch the issue or I'd simply post a PR.
Original error:
Could not find an executable at given path 'C:\Program Files (x86)\Go Agent\pipelines\Local_Scenarios\features\support\phantomjs.EXE'.If this path was not specified explicitly, it is probably a bug in Cliver. (Cliver::Dependency::NotFound)
Quoting executable_path:
def detect_version(executable_path)
executable_path = "#\"{executable_path}\"" unless executable_path.index(" ").nil?
...
end
error: Permission denied - "C:/Program\ Files\ (x86)/Go\ Agent/pipelines/Local_Scenarios/features/support/phantomjs.EXE" --version (Errno::EACCES)
Create a Clivefile format & pair it with a cliver executable that executes the underlying command with a matching executable.
Example:
Cliver::Specification.new do
add_dependency 'python', '~> 2.0', as: 'py2'
add_dependency 'pygments', '~ >7.8', '>= 7.8.1'
end
Usage:
Locates appropriate executable, then replaces self process with it and all given arguments. Possible opportunity for Clivefile.lock file for optimization here, but you know, cache invalidation.
$ cliver pygments -i foo.txt -f
See teampoltergeist/poltergeist#389
irb(main):002:0> require 'cliver'
# => true
irb(main):003:0> Cliver.detect('notepad')
# => "C:/Windows/system32/notepad.exe"
irb(main):004:0> Cliver.detect('C:/Windows/system32/notepad.exe')
# => nil
irb(main):005:0> Cliver.detect('C:\Windows\system32\notepad.exe')
# => nil
irb(main):006:0> Cliver.detect('/C/Windows/system32/notepad.exe')
# => nil
I'm trying to run tests using Poltergeist on a windows machine. When running the tests, I encounter the error below, which is trying to find the Node installation. It also fails when trying to find the Windows distribution as well.
Cliver::Dependency::NotFound: Could not find an executable at given path 'C:/.../bin/phantomjs.CMD'. If this path was not specified explicitly, it is probably a bug in [Cliver] (https://github.com/yaauie/cliver/issues).
occurred at C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/cliver-0.3.2/lib/cliver/detector.rb:45:in `detect_version'
With the following setup:
> ls -la /opt/hello/bin
total 0
drwxr-xr-x 2 root root 68 Aug 29 10:16 ./
drwxr-xr-x 4 root root 136 Aug 29 10:16 ../
-rwxr-xr-x 1 root root 0 Aug 29 10:17 hello
and
lrwxrwxrwx 1 root root 28 Apr 16 2013 /usr/local/bin/hello -> /opt/hello
Cliver detects the symlink /usr/local/bin/hello
as my hello
exectuable
EDIT: the relevant part of my $PATH
is /usr/local/bin/hello/bin:/usr/local/bin
In
https://github.com/yaauie/cliver/blob/develop/lib/cliver/detector.rb#L89
STDERR is redirected to STDOUT and also used for the version detection. This causes problems for me.
Some gem tries to find out the version of phantomjs. It's version output looks like this:
$ phantomjs --version
STDERR: Fontconfig error: "local.conf", line 18: invalid attribute 'target'
STDOUT: 1.8.1
Cliver reports that phantomjs version 18 is installed.
Two possible solutions:
If you tell me which of the solutions you favor, I'll provide you with a pull request for it.
Cliver.detect!
appears to fail when passed a constant.
module TestModule
CMD = 'gpsbabel'
def self.test
# Works
Cliver.detect!('gpsbabel')
# ArgumentError:
# Relative-path executable requirements are not supported.
Cliver.detect!(CMD)
end
end
@mschuerig opened teampoltergeist/poltergeist#415 with the following:
Here's what I get:
irb(main):009:0> phantomjs_path = Cliver.detect('phantomjs', '~> 1.8', '>= 1.8.1')
=> nil
irb(main):010:0> phantomjs_path = Cliver.detect('phantomjs', '~> 1.8')
=> nil
irb(main):011:0> phantomjs_path = Cliver.detect('phantomjs', '>= 1.8.1')
=> "/usr/bin/phantomjs"
irb(main):012:0> `#{phantomjs_path} --version`.chomp
=> "1.9.0"
Also of interest:
irb(main):013:0> Cliver::VERSION
=> "0.2.2"
irb(main):016:0> RUBY_DESCRIPTION
=> "ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]"
The system is a current Debian unstable/sid with phantomjs package 1.9.0-1.
I cannot repro this in 0.2.2 or the current 0.3.1:
phantomjs_path = Cliver.detect!('phantomjs', '~>1.8', '>=1.8.1')
# => "/usr/local/bin/phantomjs"
`#{phantomjs_path} --version`.chomp
# => "1.9.0"
@mschuerig can you try the Cliver.detect!
method? It'll raise an informative exception when the dependency cannot be met.
cliver 0.3 cannot detect the ragel version for some reason: https://travis-ci.org/whitequark/parser/jobs/12174556
WIP notes
Sometimes just making sure that the first executable on your path is the right version isn't enough; we should be able to look for an executable that satisfies the requirements, not just make sure that the first one on the path is ok. A perfect example of this is python, with the 2/3 split, where many users must have both installed.
The interface should be pretty similar to the existing Cliver::assert
, but should have an explicit return value of the full path to the executable. If no appropriate executable can be detected, this will raise like Cliver::assert
does, except that the message needs to have information about many found-and-not-good-enough binaries.
executable_path = Cliver::detect(executable, *requirements, options = {})
I am using docker for my CI, and running cucumber inside the ubuntu container is failing to find phantomjs version that was installed with npm.
cliver: /var/lib/gems/2.3.0/gems/cliver-0.3.2/lib/cliver.rb
The detector #<struct Cliver::Detector command_arg=nil, version_pattern=nil> failed to detect theversion of the executable at '/app/node_modules/phantomjs-prebuilt/bin/phantomjs'
I'm using phantomjs-prebuilt:
root@5036dec3f7b6:/app# npm ls phantomjs-prebuilt
[email protected] /app
+-- [email protected]
It seems my environment wasn't properly setup with libfontconfig
as I couldn't run:
root@6c2f2f7605a3:/app# /app/node_modules/phantomjs-prebuilt/bin/phantomjs --version
After my docker image was fixed with the dependency, I had no problem. Perhaps the error raised could be modified with the underlying stderr
so one could more easily see the source of the problem?
Breakout Case of #19 for Windows Machines on Normal Ruby (Issue previously was for JRuby)
When running tests I get the error:
Cliver::Dependency::NotFound: Could not find an executable at given path 'C:/Webdrivers for RubyMine/phantomjs.EXE'.If this path was not specified explicitly, it is probably a bug in [Cliver](https://github.com/yaauie/cliver/issues).
0.3.2
in my Gemfile / .lockOne possible issue is it wants phantomJS to have an upper case .EXE
SYSTEM PATH:
C:\Ruby22\bin
ENV PATH:
C:\ProgramData\Oracle\Java\javapath;
C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;
%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;
C:\Program Files (x86)\Skype\Phone\;
C:\Webdrivers for RubyMine\;
C:\Webdrivers;
%android_home%\platform-tools\;
C:\Program Files (x86)\Brackets\command
Luke
This is what we encountered:
Poltergeist uses cliver since 1.4.0. We set
poltergeist_options[:phantomjs] =
With a pathname object, leading to a lot of errors:
NoMethodError: undefined method `[]' for #<Pathname:0x007ff093b69028>
occurred at /Users/djungowski/.rvm/gems/ruby-2.0.0-p247/gems/cliver-0.3.2/lib/cliver/dependency.rb:71:in `block in check_compatibility!'
This is because the check_compatibility! method expects a string. It would be good if the method either supports the Pathname object (which would be useful) or uses a .to_s
This is a pre-requisite for #2. I may want to also be able to supply a PATH
-like string manually instead of relying on ENV['PATH']
# Analog of Windows `where` command, or a `which` that finds *all*
# matching executables on the supplied path.
# @param cmd [String] - the command to find
# @return [Enumerable<String>] - the executables found, lazily.
def find_executables(cmd)
return enum_for(:find_executables, cmd) unless block_given?
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each do |ext|
exe = File.join(path, "#{cmd}#{ext}")
yield exe if File.executable? exe
end
end
end
While running tests using JRuby, Capybara and Poltergeist, I get the following error:
Cliver::Dependency::NotFound: Could not find an executable at given path 'c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.EXE'.If this path was not specified explicitly, it is probably a bug in [Cliver](https://github.com/yaauie/cliver/issues).
The path to phantomjs.exe is correct and it is also part of my Windows path. Running phantomjs --version from the command prompt returns "2.1.1", so there is no doubt that the exe file is present and working.
Is there some kind of workaround that I can use to get around this problem (if it is indeed a bug, like the error message says)? Is the cause of the bug known, and are there any countermeasures? I'd really appreciate some help, as I am quite stuck.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.