Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Foodcritic not running correctly after installing 0.2.2 msi on windows 7 #165

Closed
poliva83 opened this issue Sep 21, 2014 · 7 comments · Fixed by chef-boneyard/omnibus-chef#254
Assignees
Labels
Type: Bug Doesn't work as expected.
Milestone

Comments

@poliva83
Copy link

Getting gem load error when trying to run foodcritic. I am under impression this should work after installing the msi.

C:\Users\poliva.RIMNET>foodcritic -h C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/dependency.rb:296:in to_specs': Could no
t find 'foodcritic' (>= 0) among 9 total gem(s) (Gem::LoadError)
from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/dependency.rb:307:in to_spe c' from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in gem'
from C:/opscode/chefdk/bin/foodcritic:22:in `

'``

I tested kitchen berks chef-client chef-solo chef-apply commands and then all seem to be working fine.

@lamont-granquist
Copy link
Contributor

Does chef exec foodcritic work?

@poliva83
Copy link
Author

Does not appear so...

C:\Users\poliva.RIMNET>chef exec foodcritic C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/dependency.rb:296:in to_specs': Could no
t find 'gherkin' (~> 2.11) - did find: [gherkin-2.12.2-x86-mingw32] (Gem::LoadEr
ror)
from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/specification.rb:1209:in bl ock in activate_dependencies' from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/specification.rb:1198:in ea
ch'
from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/specification.rb:1198:in ac tivate_dependencies' from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/specification.rb:1180:in ac
tivate'
from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:48:in
gem' from C:/opscode/chefdk/bin/foodcritic:22:in

'`

@poliva83
Copy link
Author

So I did have 2.0.0 ruby installed on my machine so I uninstalled it and removed old ruby from environment path.

I was then getting

C:\Users\poliva.RIMNET>foodcritic -h
'"ruby.exe"' is not recognized as an internal or external command,
operable program or batch file.

So I changed C:\opscode\chefdk\bin\foodcritic.bat to

@ECHO OFF
"%~dp0\..\embedded\bin\ruby.exe" "%~dpn0" %*

and then foodcritic works

C:\Users\poliva.RIMNET>foodcritic -h
foodcritic [cookbook_paths]
    -t, --tags TAGS                  Check against (or exclude ~) rules with the
 specified tags.
    -f, --epic-fail TAGS             Fail the build based on tags. Use 'any' to
fail on all warnings.
    -c, --chef-version VERSION       Only check against rules valid for this ver
sion of Chef.
    -B, --cookbook-path PATH         Cookbook path(s) to check.
    -C, --[no-]context               Show lines matched against rather than the
default summary.
    -E, --environment-path PATH      Environment path(s) to check.
    -I, --include PATH               Additional rule file path(s) to load.
    -G, --search-gems                Search rubygems for rule files with the pat
h foodcritic/rules/**/*.rb
    -R, --role-path PATH             Role path(s) to check.
    -S, --search-grammar PATH        Specify grammar to use when validating sear
ch syntax.
    -V, --version                    Display the foodcritic version.
    -X, --exclude PATH               Exclude path(s) from being linted.

@poliva83
Copy link
Author

Also had to change bin files to get rubocop ruby-parse ruby-rewrite and a couple others to run from command line.

@carpnick
Copy link

Looks like the chef exec command is screwing up the path environment variable:
Path=C:/opscode/chefdk/bin:C:/Users/ncarpenter/.chefdk/gem/ruby/2.0.0/bin:C:/opscode/chefdk/embedded/bin:c:\python278;......;C:\opscode\chefdk\bin

Notice there is a ":" between each of the opscode freshly added paths:
C:/opscode/chefdk/bin:C:/Users/ncarpenter/.chefdk/gem/ruby/2.0.0/bin:C:/opscode/chefdk/embedded/bin:
This needs to be semi-colons

@carpnick
Copy link

This is a generic pathing problem - not foodcritic related.

@danielsdeleo
Copy link
Contributor

Correct, this line needs to be using the ruby File::PATH_SEPARATOR constant: https://github.com/opscode/chef-dk/blob/7c4f55cd1665727203aef211bb3e5931d2ac8547/lib/chef-dk/helpers.rb#L86

@lamont-granquist lamont-granquist added this to the 0.3.0 milestone Sep 30, 2014
@sersut sersut self-assigned this Sep 30, 2014
ksubrama pushed a commit that referenced this issue Jan 11, 2016
@thommay thommay added Type: Bug Doesn't work as expected. and removed Bug labels Feb 1, 2017
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug Doesn't work as expected.
Development

Successfully merging a pull request may close this issue.

6 participants