Chef: cannot load such file -- rubocop/formatter/checkstyle_formatter - ruby

I'm running the following command:
rubocop --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --no-color --silent --rails --out checkstyle.xml
And get this error:
C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rubocop/formatter/checkstyle_formatter (LoadError)
Environment is Chef-DK 0.4.0 on Windows. I've installed the gem with:
gem install rubocop-checkstyle_formatter
RuboCop (0.28.0) is delivered within Chef-DK 0.4.0 and without Formater it is working.
Here is the page of the Formater: https://github.com/eitoball/rubocop-checkstyle_formatter
I didn't find any solution by searching with google or here in stackoverflow.
Any tipps how to fix or analyse the problem? I'm new to Ruby.

I solved this issue in a relatively hacky way but it works. So basically cd into your rubocop gem folder (like /home/ec2-user/.rvm/gems/ruby-2.1.2/gems/rubocop-0.34.2/lib/rubocop), then you'll see a dir named formatter, then cd into that formatter folder, you'll see a bunch of .rb files for different formatters.
Now here comes the solution.
touch checkstyle_formatter.rb
then copy https://github.com/eitoball/rubocop-checkstyle_formatter/blob/master/lib/rubocop/formatter/checkstyle_formatter.rb to the file you just created.
Then you should be good to go

Related

ERROR: While executing gem ... (Zlib::GzipFile::Error) not in gzip format

I am developing a Sencha touch 2 application. I have been following the "Styling the user interface of a Sencha Touch application" tutorial on theming of secha touch applications.
It requires me to install Ruby, Compass and SASS.
I installed Ruby using the installer from rubyinstaller.org.
On executing the following command, I get the expected result which confirms correct installation:
C:\>ruby -v
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]
Current source is up to date:
C:\>gem sources
** CURRENT SOURCES **
http://rubygems.org/
Next, since I am behind a proxy, I used the following command to install HAML/Compass:
C:\>gem install -p [proxy:port] compass
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format**
Can someone help me? I found solutions such as system update, gem sources update, but everything is up to date on my system.
Edit:
C:\>gem install compass
works perfectly fine on my private system. When I try the same command from my workplace I need to use the proxy as mentioned above and that results in an error.
I assume the ERROR occurs since the web sense at my workplace blocks these downloads.
Solution: I downloaded the required gems: chunky_png, fssm, compass, sass, haml etc.. directly from http://rubygems.org/gems and placed these gems in my local directory.
After this I tried gem install compass. This first searches your local directory. On finding the required gems, installation takes place. Does not require connection to the ruby website.
Note: Run the command from the path where the gems are located
eg: I have placed the gems in C:\Ruby193\lib\ruby\gems\1.9.1\gems
So I run the following command :
C:\Ruby193\lib\ruby\gems\1.9.1\gems>gem install compass
I had a similar problem, it worked on my own private laptop, but failed while using a virtual server at work (running Ubuntu 12.10) that used a proxy.
Following the suggestion I found here, from the command line I defined:
export HTTPS_PROXY=proxy-address:proxy-port-number
export HTTP_PROXY=proxy-address:proxy-port-number
and then my gem install package worked fine.

How to bundle local gem dependancies in IronWorker

I have a Ruby IronWorker which depends on a private gem that isn't published to RubyGems.
Is there a way to merge this local mygemname-0.0.1.gem into my IronWorker in the .worker file?
I'm hoping to be able to specify something the following in myruby.worker:
gem 'mygemname', '>=0.0.1', :path=> 'vendor/bundle'
Currently this give the following error
.rvm/gems/ruby-1.9.3-p0/gems/iron_worker_ng-0.12.2/lib/iron_worker_ng/code/base.rb:79 :in `eval':
wrong number of arguments (3 for 2) (ArgumentError)
Hoping for defaults gives:
gem 'mygemname', '>=0.0.1'
Gives the following error
Could not find gem 'mygemname (>= 0.0.1) ruby' in the gems available on this machine.
Am I on the right track trying to get this to work via the .worker file? Or should I be looking into specifying a custom build step?
If your unpublished gem itself has dependancies, you need to do a little massaging to get things going. Here is a technique that works for me:
mygem.worker
runtime "ruby"
#Merge in an unpublished local gem
dir '../opensource-cli-tools/facebook_exporter', '__gems__/gems'
file '../opensource-cli-tools/facebook_exporter/mygem.gemspec', '__gems__/specifications'
#Merge in a custom build script to fetch the unpublished gem's dependancies
file "Gemfile"
file "install_dependancies.sh"
remote_build_command 'chmod +x install_dependancies.sh && ./install_dependancies.sh'
#Run the puppy!
exec "run.rb"
install_dependancies.sh
echo "Installing dependancies to __gems__/"
gem install bundler --install-dir ./__gems__ --no-ri --no-rdoc
bundle install --standalone --path ./__gems__
cp -R ./__gems__/ruby/*/* ./__gems__
rm -rf ./__gems__/ruby
echo "Fixing install location of mygem"
mv ./__gems__/gems/mygem ./__gems__/gems/mygem-0.0.1
As far as i know, git and local paths unsupported right now.
Here is way to manually include local gem:
Add these lines to .worker file:
dir '../vendor/bundle/mygemname', '__gems__/gems'
file '../vendor/bundle/mygemname/mygemname.gemspec', '__gems__/specifications'

Viewing a Gem's Source Code

Ruby dabbler/newbie here who's not familiar with the ecosystem, so apologies if this is one of those super duh questions.
Is there a way to view all the files and/or source code installed by a gem? That is, I just ran
$ gem install sass
And the sass gem is now a part of my local system
$ gem list --local
...
sass (3.1.16, 3.1.2)
...
I want to know what the gem install command put on my system. Is there a command I can run to see all the files installed by the gem?
After some googling, man gem and gem help commands, I discovered the contents command.
$ gem contents sass
However, when I run this command with the aforementioned sass gem, I get the following results
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/engine_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/functions_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/extend_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/logger_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/css2sass_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/conversion_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/script_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/util/subset_map_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/util/multibyte_string_scanner_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/callbacks_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/importer_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/scss/css_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/scss/scss_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/scss/rx_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/util_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/script_conversion_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/less_conversion_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/cache_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/plugin_test.rb
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/bin/sass
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/bin/sass-convert
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/bin/scss
However, this list seems incomplete as I know there are files in
.../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.2/lib/
Why does contents not show the files from lib?
Is it possible for a gem installer to install files outside of the gems folder?
Is there a command that can show everything installed by a gem?
gem has an unpack command: http://guides.rubygems.org/command-reference/#gem-unpack
gem unpack rake
ls rake-0.4.3/
There are two really good ways to do this. There is another gem which allows you to open the gem and edit. This gem is call gem-open
gem install gem-open
then
gem open sass
Another way is to generate your own rdocs.
gem rdoc sass
You can then look at your rdocs by
gem server
Also if you are using rvm, you can type rvm info and it will show GEM_HOME location.
This will be where all your gems source code is.
cd $GEM_HOME
cd gems/sass-3.1.2/
Update:
This is the way I mostly do this now, when using bundler.
cd $(bundle show sass)
This will be the version of sass in your Gemfile.
I usually open a gem by running this command from the console
EDITOR=<your editor> bundle open <name of gem>
The lib/ directory you mentioned is for version 3.1.2 of the gem; gem contents without --version will just list one version (it appears to pick the newest version, but I'm unable to verify this is always true). What output do you get for gem contents --version 3.1.2 sass?
You can also use just rename the .gem file to .tar and extract as a posix archive. The source code is inside it in the lib folder. See https://blog.srcclr.com/extracting-ruby-source-code-from-gem-packages/ for more details.
In addition to gem contents, another command you might find useful is gem environment. If you have multiple paths for your gem installations, they will all be listed under the "GEM PATHS" label.

Can't create pdfs with pdfkit - PDFKit::NoExecutableError

I got pdfkit install and even set up wkhtmltopdf installed as well however I'm getting the following error everytime I try to create a pdf.
PDFKit::NoExecutableError
No wkhtmltopdf executable found at bundler: command not found: which
Install missing gem executables with `bundle install`
>> Please install wkhtmltopdf - https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF
My Gemfile has the following:
gem 'jquery-rails'
gem 'devise'
gem 'carrierwave'
gem "wkhtmltopdf"
gem 'pdfkit'
And my application.rb has the following entry:
config.middleware.use "PDFKit::Middleware", :print_media_type => true
am I missing something here - I've run a bundle install but still get this error everytime I try to create a pdf. Please help
You should read Install readme here:
https://github.com/jdpace/PDFKit
so you need to install wkhtmltopdf manualy:
https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF
or like this
gem install wkhtmltopdf-binary
PS
check which wkhtmltopdf
and create new file config/initializers/pdfkit.rb
PDFKit.configure do |config|
config.wkhtmltopdf = 'PATH/TO/wkhtmltopdf'
end
Ali,
I don't see you mention which operating system you're on. Fl00r, and I, are both assuming that it's a Linux system, so adjust accordingly. This is what I needed to do to make PDFKit work with wkhtmltopdf for my Rails application running on 64-bit Ubuntu 12.04 LTS.
Remove any reference to wkhtmltopdf or wkhtmltopdf-binary from your Gemfile.
Add only gem 'pdfkit', :require => 'pdfkit' to your Gemfile
In your config/initializers/mime_types.rb file add
Mime::Type.register "application/pdf", :pdf
Remove any config/initializers/pdfkit.rb file
Uninstall the gems from the server that you're running the Rails application on
gem uninstall wkhtmltopdf -a
gem uninstall wkhtmltopdf-binary -a
Download to your server wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 from the project download site here. There is a bug in the latest suggested download versions that prevent a user from being able to select and copy text from a generated PDF, but this version doesn't have that bug. This issue is referenced at http://code.google.com/p/wkhtmltopdf/issues/detail?id=886
Extract the executable from the tar archive
tar -xvf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
Move it to the /usr/local/bin/ directory
sudo mv wkhtmltopdf-0.10.0.rc2 /usr/local/bin/
Now setup a symbolic link to the file so it's easy to upgrade at a later point
sudo ln -s /usr/local/bin/wkhtmltopdf-0.10.0.rc2 /usr/local/bin/wkhtmltopdf
Set the permissions on the file
sudo chmod 755 /usr/local/bin/wkhtmltopdf-0.10.0.rc2
After doing all of this, and restarting my server, PDFKit will now use the wkhtmltopdf that I have installed on the server.
Caveat: On one occasion my Rails application started reporting that it couldn't find the wkhtmltopdf executable in the path, not sure why as nothing changed. Restarting the server corrected this issue.
None of the above worked for me. I tried the solution posted in here https://github.com/pdfkit/pdfkit/issues/123

What's wrong with my ruby gems setup?

I'm trying to run a ruby file which imports a gem. The ya2yaml gem is installed, yet somehow it is not found:
$ cat delme.rb
require 'rubygems'
require 'ya2yaml'
$ ruby delme.rb
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- ya2yaml (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from delme.rb:2
I installed the gem using: sudo gem install ya2yaml and I know that the gem is actually installed:
$ gem list --local | grep ya2yaml
ya2yaml (0.26)
Also, the following works from a rails program I just downloaded:
sudo rake gems
However the following fails:rake gems
Which leads me to think that there may be a permissions problem somewhere.
Why can't the gem be found? What can I do to diagnose this?
Thanks!
The thing I would do in a situation like this:
Search for the gem's location on your system. Use this command:
find / -name ya2yaml
Check that the found directory is added to your PATH system variable by doing this:
echo $PATH
If the path where ya2yaml gem is located is not listed in the PATH variable's value, add it:
PATH=$PATH:/gem/location/directory
export PATH
I hope you'll find these steps helpful. Good luck!
Instead of require 'rubygems' inside delme.rb, try starting ruby with -rubygems:
$ ruby -rubygems delme.rb
I've certainly seen this error before. Unfortunately I don't know what causes it. I do know that if you see it on Linux and you've installed gem via your package manager (synaptic / yum / etc) then you can generally fix it by installing gem by hand from their website. The instructions there are pretty straight-forward.
(Your command line looks unix-y, so it seems to me that you may be on Linux. If you're on a Mac, it's certainly worth trying anyway.)
UPDATE: Linux, then. Ta.

Resources