Chef Test Kitchen fails to load ffi-yajl c-extention - ruby

Yesterday my system configuration was such that I could smoothly run kitchen test without issue. I don't know what happened, but this morning the configuration was all screwy and Kitchen wouldn't run. Something about Berkshelf having no cdhash or something. I spent literally all day hammering it out, and I've finally got kitchen test running to completion, but partway through (after Vagrant brings up the VM and it connects over SSH and starts to converge) it tells me:
...
Vagrant instance <default-centos-6> created.
Finished creating <default-centos-6> (2m20.75s).
-----> Converging <default-centos-6>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 8.0.5...
failed to load the ffi-yajl c-extension, falling back to ffi interface
...
That last line about the ffi-yajl c-extension is the problem. Like I said, it still runs the tests to completion, but it pauses here and ffi takes a while to run, while ffi-yajl used to be pretty fast. Also, it worked yesterday before whatever hex took over my computer. For the purpose of expedience in running tests against multiple configurations, it'd be great if the faster ffi-yajl stuff could work but I don't know what to do. I found an ancient git issue on the ffi repo from 2015 (and on windows, I'm on Mac 12.5.1, if it matters) but I assume whatever upcoming patch mentioned in the response has since been released since 2015.
gem list ffi-yajl says I have 2.4.0. If it matters, the ffi version it's falling back to is 1.15.5.
When I do which -a ruby, it shows me the system ruby (/usr/bin/ruby) and the chef-workstation ruby (/opt/chef-workstation/embedded/bin/ruby). I think one of the steps I did earlier to fix my configuration was to tell it to use the chef-workstation ruby, but I don't remember how I did that (maybe the PATH variable?). Could it be that ffi-yajl's gem is in the wrong place associated with the system ruby? How would I correct that if that's the case? How would I determine if that's the problem?
I tried gem install ffi-yajl, but no luck. I tried bundler pristine ffi-yajl; bundle install, but also not helpful. Before you ask, I've been tasked with working on this portion of our tech stack, partially because we have a lot of tech debt like this, and partially because it's an opportunity for me to learn something new about our tooling. In other words: I'm completely inexperienced with all things Ruby/Gems/Bundler, so I've been throwing ideas on the wall and hoping something sticks, but I'm still searching. I'm out of ideas.

Related

Ruby gem version numbering

I recently started my first gem, but as I was familiarizing myself with the gem command, how the build process worked, etc., I published several versions of my gem with varying version numbers before I realized I could simply run rake install.
I know the site doesn't give any information regarding deleting/resetting a gem, but is there any way to reset a gem that I started? When I go to "previous versions", every dummy version I published is listed regardless if I yanked it or not. Is there a way to reset this?

Rubymine use local gem configuration

I'm running Ruby mine 7.1.2 on Windows and I'm having difficulty with it because it seems to want to use its own gems and version of fun where. My application works fine from the command line if I do bundle install or bundle exec rails script but when I try to run from the IDE it complains about missing gems.
I could just try to reinstall all the gems via ruby mine but some of the gems require special customization in Windows and doing that from the command line is much easier. Is there anyway I can have ruby mine just use the gems which are already installed?
Rubymine will usually bundle your ruby SDK (i.e. ruby itself) and all it's associated gems so that you don't end up with weird configuration dependencies.
If you want to circumvent that then follow an official guide. In addition to that guide, be aware that there are also per-run SDK settings. These kick in when running or debugging a RubyMine project and need to be configured in the run -> configuration settings dialog.
My (unsolicited) additional advice is that I'd recommend figuring out what aspects of your global ruby installation are causing issues with RubyMine's bundle installer. The reason RubyMine sandboxes several SDKs is to reduce major headaches when you go to deploy your applications. Without it, you might encounter dependency hell when you deploy your application. From my personal (and extremely annoying) experience, rushing these initial set-up steps tend to come back with vengeance when you want to run ruby apps elsewhere.

Errors when trying to set up Ruby on Rails and connect to localhost:3000

I apologize ahead of time if I don't do a good job of explaining this. I am a complete beginner and I have been struggling to find anything online that is written with that in mind.
So far, my only experience is doing the Javascript and Ruby sections of Codecademy.com. I read that I should have some knowledge of Ruby before trying out Rails.
So I found this site Getting Started with Rails and I tried to follow the steps and do exactly as it said. It even says at the beginning, "This guide is designed for beginners who want to get started with a Rails application from scratch. It does not assume that you have any prior experience with Rails." It also says, "The best way to use this guide is to follow each step as it happens, no code or step needed to make this example application has been left out, so you can literally follow along step by step."
Anyway, I'm using Windows 7 Home Premium and I already had Ruby installed. When I go into the command prompt and type ruby -v it says ruby 1.9.3p484 (2013-11-22) [i386-mingw32]. When I type rails -v it says 4.0.2. When I type gem -v I get 1.8.28. Now in the instructions it links to a place to download RubyGems and it says that it's 2.2.2. I downloaded that and clicked the setup.rb file and it said it installed it, yet the version is still 1.8.28. I don't know why, but it says it's installed so I assumed it did what it was supposed to do. I'm probably wrong.
Then I'm supposed to type rails server and then go to localhost:3000 and see some kind of default page. However, when I type rails server I get these errors. Sorry for the copy and paste, but I'm not allowed to post a pic of the command prompt.
E:\Apps\RailsWork\blog>rails server
←[31mCould not find gem 'rails (= 4.0.2) x86-mingw32' in the gems available on t
his machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
E:\Apps\RailsWork\blog>bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.9.0)
Installing atomic (1.1.16)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.
"E:/Apps/Rails Installer Package/RailsInstaller/Ruby1.9.3/bin/ruby.exe"
extconf.rb
E:/Apps/Rails Installer Package/RailsInstaller/Ruby1.9.3/bin/ruby.exe: invalid o
ption -P (-h will show valid options) (RuntimeError)
Gem files will remain installed in E:/Apps/Rails Installer Package/RailsInstalle
r/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/atomic-1.1.16 for inspection.
Results logged to E:/Apps/Rails Installer Package/RailsInstaller/Ruby1.9.3/lib/r
uby/gems/1.9.1/gems/atomic-1.1.16/ext/gem_make.out
An error occurred while installing atomic (1.1.16), and Bundler cannot continue.
Make sure that `gem install atomic -v '1.1.16'` succeeds before bundling.
E:\Apps\RailsWork\blog>
You can see that it tells me to type bundle install, but when I try that I get another few error messages. I've tried googling these error messages, and some of them even linked me to questions asked on this site, but most of them were close, but not exactly what I'm having trouble with, and all of them have answers that are away over my head.
I also thought maybe it didn't matter and so I tried to go to localhost:3000 anyway, but I get the "Oops! Google Chrome could not connect to localhost:3000" message.
I'm a total noob. Everything I look up just gets me more confused so I'm hoping the answer is kind of simple and that someone can point it out for me in a beginner-friendly kind of way. I feel like once I get over this hump of getting all of this set up, I can actually start learning and gaining some experience. I had a blast learning Ruby so far and I hope to continue on with learning Rails. Thanks for reading and any help would be greatly appreciated. Oh, and if anyone has any better suggestions for a beginner's guide to all of this stuff, I'd also really appreciate it. Thanks again.
On windows it is probably the easiest to get started with the one click rails installer as this will also install the devkit although I see that it is not being kept up to date with ruby or rails versions. Although it does work Windows is not the best environment for Rails development. Starting up the rails server and running tests is much slower than on mac or linux and will get frustrating after a while. Also some handy gems and third party tools doesn't work on windows. Save yourself the pain and run ubuntu on a vm (virtualbox is good). Also use a ruby version manager like rbenv otherwise it becomes a royal pain to upgrade ruby later.

Ruby problem(bug)- in rake gem

i am running ruby 1.9.2p0 on rails on windows OS with rubymine 3.1.1.
i use it for גseveral weeks.
a few days ago- i tried to run my project from rubymine and the console notification was:
"Could not find rake-0.8.7 in any of the sources
Process finished with exit code 7"
i googled it and i found reference to this problem in several places. the solution repeated most often was to delete the non-versioned "rake.gemspec" file.
i tried this solution but the problem is not resolved, it still says the same notification.
i trying to solve this problem for several days!!!
please help me if you know how!!!
thanks a lot in advanced!
Asaf,
I've had literally hours of frustration dealing with similar problems. The solution can be a challenge to track down, because there are numerous reasons you could be having the problem. I'm no expert myself, but I'll try to pass on some of what I've learned.
First, you mentioned getting an error about Rake, but didn't mention that you had tried to actually run Rake. Are you getting the error upon loading up RubyMine or specifically after running a Rake command?
Next, if you are running a Rake command and getting an error, you should take note that WHERE you run the command from is pretty important. For example, if you keep a Terminal window open like I do, and run the Rake command from Terminal, you won't necessarily get the same results you would get by running Rake from RubyMine itself. The reason for this was not self-evident when I first started with RubyMine, but I think it comes down to this:
The Ruby SDK and Gems preferences in RubyMine should be determining what types of dependency errors you get from within RubyMine. So you might start by looking there to see if there are any dependency errors. Next, I would guess that you're running RVM? Please be aware that it is completely possible to be using one RVM set in RubyMine (check the Ruby Interpreter in SDK and Gems Preferences to see which one you're using) and an entirely different RVM in Terminal (the command "RVM info" should get you the version you're using). If those don't match, you could very well get different results from both RubyMine and Terminal, even when running exactly the same commands.
My solution to this problem was to carefully ensure that both of my environments matched. I think you can set RVM defaults by typing "rvm default" plus the version you want to default to. That way both your Terminal and RubyMine environments match.
Lastly, be aware that RubyMine allows more than one version of a Gem to be installed at the same time. So, if you're getting an error that a Gem is failing because some dependency requires a specific version, you can tell RubyMine to install multiple versions. Do this thru the SDK manager, select the Gem, then click "Select Versions".
Hopefully some of this information applies to your issue. I sort of did the shotgun approach, because I'm not really sure what is causing your error, but maybe some of this can put you on the right path. One final note would be this: Use your Gemfile to control Gem versions, if need be. I've spent hours of frustration over broken dependencies, only to discover that the reason for the break was me telling RubyMine to update all my Gems to the latest version. The latest version of a particular Gem isn't necessarily backwards compatible with previous versions, and blindly updating Gems can cause huge problems.
Asaf, you should delete rake.gemspec and run gem install rake to get problem fixed

Should I get gems from RubyForge, Github, or Gemcutter?

I'm confused about the world of Ruby Gems. There are several well-known repositories. Which is the right one, or does it matter?
I guess Gemcutter is the hip repository right now. They definitely have the nicest-looking website. Does that mean I should get my gems from there?
The main reason I'm asking is that I want to make sure I'm getting the latest release of the gem. If I don't specify the source, am I in danger of installing a crap version of the gem, or am I bugging?
Why is there more than one repository anyway?
GitHub gem building is defunct -- it got disabled for an upgrade, and was never re-enabled because GemCutter is taking over that role. There are no new gems being generated on GitHub.
RubyForge is planning to phase phase out gem hosting too -- GemCutter will become the standard source for gems.
Edit: The whole migration plan is here
Go gemcutter. It's been publicized that gemcutter is going to become the new de facto. But, if you can't find the gem on gemcutter, you have to look at github or rubyforge. Hopefully most people will (if they haven't already) start moving towards gemcutter.
I think that's where "we" are at right now.
Why is there more than one repository anyway?
Because you can run your very own gem server and install from that (some folks use it on large deployments to host their own gems).

Resources