El Capitan + Ruby/Brew/major issues - ruby

I've read a ton about how El Capitan's SIP messes up brew, ruby, and it's gems. The most recent thing I read is that brew was updated to better support El Capitan, so I followed a number of commands from an article online and apparently cleaned my whole system up and reinstalled all gems. Now, from terminal, everything works great. I don't have to write anything special to install gems... just gem install <name>.
However, SublimeText seems to be using a different Ruby. If I type which ruby, it shows as /usr/local/bin/ruby. But in SublimeText, it's showing this error about not finding the right gem (mechanize in this case): /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire': cannot load such file -- mechanize (LoadError)`
I tried creating a different build system file for Ruby, which points to ruby at /usr/local/bin/ruby, but it still shows this error (but below, it shows [cmd: ['/usr/local/bin/ruby']...
This has also caused me major issues trying to get the shoes gem to install.
Long question shortened: is there a definitive way to clear my system of all past brew, ruby, gems, etc etc, and redo it in a proper way that actually works for El Capitan?

Checkout #paskal answer here: Ruby 'require' error: cannot load such file
Try changing require <file name> with require "./<File name>".

Related

How do I get rrdtool from homebrew to work with ruby on macOS

In our Rails application we do require 'RRD' at some point, but that results in a cannot load such file -- RRD. So obviously I used homebrew to install rrdtool, but the error remains.
The docs at https://oss.oetiker.ch/rrdtool/prog/rrdruby.en.html provide two options:
Either:
$: << '/path/to/rrdtool/lib/ruby/1.8/i386-linux'
require "RRD"
In my /opt/homebrew/Cellar/rrdtool/1.8.0/lib directory there's no mention of ruby, which is because of the --disable-ruby-site-install flag in the formula, because when I skip that flag I do actually get something: /opt/homebrew/Cellar/rrdtool/1.8.0/lib/ruby/2.6.0/universal-darwin21. However replacing the path/to string with this path still gives the error.
Or:
If you use the --ruby-site-install configure option you can drop the $: line since the RRDtool module will be found automatically.
Which is a little confusing (and probably outdated) because here it seems that ruby site install is disabled by default and you have to enable it proactively, whereas in the formula it's actually actively disabled.
Either way: both options didn't do the trick for me and if there's a solution without homebrew that's also fine.
For good measure: I'm on macOS Monterey
TL;DR
For the most part, I'd say that using a non-standard gem without a Ruby version manager is your main issue. There are instructions on the rrdruby site for installing it, but they don't follow typical conventions, so your mileage will vary.
Some Practical Suggestions
The require keyword is for gems, not binaries. You need to have an rrdtool-related gem installed, available to your Ruby instance (usually through a Bundler Gemfile or gemspec, or via the RUBYOPTS environment variable or your in-process Ruby $LOAD_PATH), and then require the correct name of the gem in your code. For example, using the older rrd-ffi gem:
# use sudo if you're installing it to the system,
# but I would strongly recommend a ruby version
# manager instead
gem install rrd-ffi
# in your Ruby class/module file
require "rrd"
For the gem you seem to be using, you have to compile the gem first to make it usable, and then ensure it's available in your Ruby $LOAD_PATH (or other gem lookup mechanism) before trying to require it. The error message you're seeing is basically telling you that a gem with that name is not available as called within any of the standard lookup locations.
Again, I'd suggest reading the build documentation for your gem, and then seeing if you can install it as part of a Bundler bundle, RVM gemset, or other non-system approach if you can. Otherwise, follow the directions for the rrdruby tool, which is not available as a standard Rubygems.org gem, in order to make it available before trying to require it.
Beware of Outdated or Non-Standard Gems
Most of the RRD gems I found were quite old; most were 7-8 years old or older, so their compatibility with current Rubies is potentially suspect. The gem-builder you're using is newer, but doesn't seem to be designed as a standard gem, so you need to build it and install it in a suitable lookup path before it can be required. Installing gems as system gems is almost always a bad idea, so I'd strongly recommend building it from source and using a ruby version manager rather than following the rrdtool author's atypical suggestions. YMMV.

Cannot install RuboCop on RubyMine

I'm opening ruby file via RubyMine. IDE suggests installing RuboCop. I accept it, but after a few seconds it shows:
Following gems were not installed: rubocop (1.0.0): Cancelled
Documentation says its problem with interpreter path. Problem is its already set. Even when i try to add it like documentation says, it won't let me, because its already set.
Any ideas what i can do? I have been using VisualStudio Code without issues before it, but Ruby support is pretty poor, i had to use terminal, while for example python has full support and you can just run program with one button.

rbenv install fails because of ruby-lang.org layout change (or permanent failure?)

Of all the days I chose today to switch from rvm to rbenv. All went well far enough, there are good tutorials on this, but the fun stopped when I tried to install ruby 1.9.3.
rbenv install 1.9.3
proposed to install 1.9.3-p448 as the current version which seems ok to me, so I tried
rbenv install 1.9.3-p448
and went down from there on. It will look up something on ...cloudfront.net and then tried to fetch ruby-1.9.3-p448.tar.gz from the "usual location" which it considers to be
http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.gz
which fails with
/usr/local/bin/ruby-build: line 144: pushd: ruby-1.9.3-p448: No such file or directory
plus a final 404-error and a host of followup error messages.
As it turns out the link above is identical to the one published on http://www.ruby-lang.org/en/downloads/ which I would consider as "official" a link as you might find for Ruby. So if you go to ruby-lang.org manually (or using the link above) you will also find a broken download (as of 2013-08-06 17:06)!
I guess this is a temporary issue and the downloads will return (2.0.0 link is also broken by the way). Not to much of a problem for me at the moment as 1.9.2 can still be installed (and I am stuck with that at my current hosting provider ...), but anyways: Are there any other options I would have to install a ruby with rbenv without these "official" distributions?
Looks like ruby-lang.org has been going on and off line for a couple of hours now.
ruby-lang status: http://www.ruby-lang.org/en/news/2013/08/06/status-issue/
GitHub Issue: https://github.com/ruby/www.ruby-lang.org/issues/259
just tested overriding the mirror for ruby-build in cap...
rbenv uses ruby-build. You can override the mirror in ruby-build url in 2 ways:
Specifying a custom ruby version (requires you to write out a config in ruby-build/share/ruby-build/my-custom-ruby
Overriding the mirror url (requires the checksum to be the same), i.e., RUBY_BUILD_MIRROR_URL= http://mirrors.ibiblio.org/ruby/2.0/ruby-2.0.0-p247.tar.gz
env RUBY_BUILD_MIRROR_URL=http://mirrors.ibiblio.org/ruby/2.0/ruby-2.0.0-p247.tar.gz ~/.rbenv/bin/rbenv install 2.0.0-p247
I had this same problem, and I was able to work around it by editing the ruby-build recipe for the particular version of Ruby I needed to download.
I installed ruby-build as an rbenv plugin, so the recipe lives here:
~/.rbenv/plugins/ruby-build/share/ruby-build
Here's the edited version of the recipe:
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
install_package "ruby-1.9.3-p448" "http://mirrors.ibiblio.org/ruby/1.9/ruby-1.9.3-p448.tar.gz#a893cff26bcf351b8975ebf2a63b1023"
#install_package "ruby-1.9.3-p448" "ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.gz#a893cff26bcf351b8975ebf2a63b1023"
I did not try this, but you might be able to achieve a similar result by following the instructions for specifying package download mirrors.

RVM, FSEvents, and CarbonCore on OS X

I'm setting up a project that uses SASS, which uses FSEvents to keep from polling the disk. It seems that this doesn't play nice with RVM, however. That means that when I run sass --watch I get this warning:
Warning: Unable to load CarbonCore. FSEvents will be unavailable.
I realize that it will still work, but I don't want to be polling my disk constantly. I want to get it working with FSEvents. The best information I could find about this was this thread:
http://groups.google.com/group/compass-users/browse_thread/thread/df7d9d0da9ec1eb1
I reinstalled my RVM Ruby (using 1.9.2) as described by Brandon Mathis and downloaded the linked RubyCocoa. However, I get an error on the first step of installing RubyCocoa:
[rvm 1.9.2] ~/Downloads/RubyCocoa-1.0.0 $ ruby install.rb config --build-universal=yes
install.rb: entering config phase...
create ext/rubycocoa/extconf.rb
create framework/GeneratedConfig.xcconfig
create framework/src/objc/Version.h
create tests/Makefile
---> framework
create /Users/xxx/Downloads/RubyCocoa-1.0.0/framework/src/objc/osx_ruby.h ...
config failed
hook /Users/xxx/Downloads/RubyCocoa-1.0.0/framework/post-config.rb failed:
No such file or directory - /Users/xxx/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/x86_64-darwin10.6.0/ruby.h
try 'ruby install.rb --help' for usage
It looks like the problem stems from this being an older version of RubyCocoa (I notice the missing file has 1.9.1 in the path), but in the Google Groups post, Brandon Mathis says specifically to use the version he links and not the newest one.
Does anyone know how to get this configured, or have a link to a recent, hopefully simpler and clearer guide to getting FSEvents working with RVM?
Versions in question:
RVM 1.2.0
Ruby 1.9.2 patch level 136 (installed via RVM)
Mac OS X 10.6.6
HAML gem 3.0.25 (SASS is part of HAML)
Thanks!
I wrote FSSM, which is what HAML/SASS/Compass use for their filesystem watching backend. While rubycocoa isn't supported in 1.9.x, the latest git version of FSSM has pretty solid support for rb-fsevent. This library currently has other limitations, like only being able to monitor one path (parent directory is a must here), but I'm working on it. ;)
I'd highly suggest installing rb-fsevent, and then FSSM from github: https://github.com/ttilley/fssm
If you have any problems, please don't hesitate to file an issue in the tracker. FSSM is a currently maintained project, and it was originally written to help Chris Eppstein out with providing watch functionality in compass (which was later adopted in sass itself). Ease of use via these libraries is my absolute top priority.
This is kind of a lost battle. You can copy the contents of the include/ruby folder from the Ruby source code to that location /Users/xxx/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/x86_64-darwin10.6.0/ which will let you run the config command, but after that you will get a lot of errors on the setup command and you won't be able to install it all. People say RubyCocoa doesn't work with 1.9.2 and I don't know if anyone managed to make it work.
I tried the FSSM method above, to no avail...
Gemfile now has:
group :development do
gem 'rb-fsevent'
gem 'fssm', :git => 'https://github.com/ttilley/fssm.git'
end
which installs:
fssm (0.2.6.1)
rb-fsevent (0.4.0)
Still getting this tho:
Warning: Unable to load CarbonCore. FSEvents will be unavailable.
Anyone have install steps to make FSSM work nicely?

Using curb gem and libcurl on Windows

I am trying to install the curb gem, which is libcurl bindings for Ruby, and of course I need to have "A working (lib)curl installation, with development stuff" installed on my computer. So, I went to the cURL Download Wizard and downloaded this package.
But adding the bin into my PATH does not produce improvement and I still get an error when I try to install the curb gem, such as:
extconf.rb:19: Can't find libcurl or curl/curl.h
(RuntimeError)
Even though, curl is already in the PATH.
EDIT: I also tried raking the gem, as per the instructions. It fails saying "make failed" and throwing a bunch of errors like this:
C:/Ruby/lib/ruby/gems/1.8/gems/curb-0.7.7.1/ext/curb_postfield.c:76:
undefined reference to
`_imp__curl_formadd'
Execute Below command for windows only and its works
gem install curb --platform=mswin32
I realise this is a very old question, but I had this exact problem today and found the instructions on someone else's site. These worked for me so I thought I would share them since people with this issue are most likely to come across StackOverflow first: http://jes.al/2012/10/installing-curb-gem-on-windows-7/
In a nutshell:
Get the 32-bit development version of curl (see my notes below)
Add the curl bin directory to your PATH
Run the following command (replacing the paths to curl as necessary)
gem install curb --platform=ruby -- -- --with-curl-lib="C:/curl-7.27.0-devel-mingw32/bin" --with-curl-include="C:/curl-7.27.0-devel-mingw32/include"
A couple of personal notes:
Even though I am on 64-bit Windows 7, I had to download the 32-bit libcurl version under "Win32 - Generic", identified as "Win32 2000/XP zip".
I got the error c:/Ruby193/lib/ruby/1.9.1/mkmf.rb:246:in 'initialize': Permission denied - mkmftmp1.log (Errno::EACCES) while installing the gem. This rather messed up page here suggested that it might be a problem with my anti-virus, and that just retrying a couple of times might work, and indeed, it did.

Resources