How do I specify which gem to use when using rbenv. Multiple versions same gem installed - ruby

I've been using Sass 3.2.13.
I want to try out the sourcemap generation in 3.3, so I installed 3.3.
'gem list | grep sass' returns
sass (3.3.0.rc.5, 3.2.14)
I would like to invoke sass 3.3 from the commandline. I'm not using sass from a within a ruby project.
I discovered that format should work:
gem_name __versionNum__ --opts
So, I've tried this:
sass _3.3.0.rc.5_ --watch --sourcemap sass/site.sass: css/site2.css
The resulting stack trace returns
"Could not find sass (= 3.3.0.rc.5)..."
I've tried variations, like 3.3.0, 3.3, but these return stack traces with the same message about not being able to find the specified version.

Turns out that I was calling the wrong 'sass' binary.
Instead of using my rbenv gem, I was using 'sass' from '/usr/local/bin'.
I've deleted system sass. Now when I call 'sass' I get the version offered by the gem I installed via rbenv.
Yes, I know I shouldn't be deleting system binaries. It's a dirty, dirty thing to do. In the desperate case of removing system ruby from ubuntu, I think the measure is justifiable.

Related

How to use Susy2 with Compass / SASS?

I'm trying to figure out how to get Susy2 working alongside compass on my local system, and I've been all over trying to find the answer.
error sass/screen.scss (Line 4 of sass/_base.scss: File to import not found or unreadable: susy.
Load paths:
/Users/jem/Desktop/base/sass
/usr/local/lib/ruby/gems/2.1.0/gems/compass-core-1.0.0.alpha.21/stylesheets
/Users/jem/.compass/extensions/compass-normalize/stylesheets
/Users/jem/.compass/extensions/compass-recipes-master/stylesheets
/Users/jem/.compass/extensions/toolkit/stylesheets
/usr/local/lib/ruby/gems/2.1.0/gems/sassy-maps-0.4.0/sass
/usr/local/lib/ruby/gems/2.1.0/gems/breakpoint-2.4.2/stylesheets
Compass::SpriteImporter
Sass::Globbing::Importer)
ArgumentError on line ["161"] of /usr/local/lib/ruby/gems/2.1.0/gems/sass-3.3.3/lib/sass/error.rb: wrong number of arguments (1 for 2)
Run with --trace to see the full backtrace
I hit this error continually (although occasionally for other gems as well). I feel like I've tried every combination of installing and uninstalling gems, ruby, bundler, etc.
Instructions continually point me toward:
Using Bundler to manage the gems (I am).
Make sure require "susy" is in my config.rb (Yup.)
Make sure I'm on the new alpha version of compass (using 1.0.0.alpha.20)
I'm not having any luck, and I can only assume it's something going on with my local system (OS 10.9, using Ruby 2.1.2 with RVM to stay separate from the system ruby). I had susy working once on a separate linux box, but when I brought the code here I keep running into these susy issues.
If you are using Bundler, your Gemfile should include:
gem "susy", "~>2.1.0"
gem "sass", "~>3.3.0"
gem "breakpoint", "~>2.4.0"
Bundler should set up all the other dependencies you need.
Since you are using RVM for your Ruby installation, are you sure that you are using the default Ruby (as per RVM) or the system Ruby which might be only Ruby 1.8.7 (rather than Ruby 2.0)?

Multiple versions of a gem

I'm currently using the gems scss-lint and compass; however scss-lint uses sass#3.3.0.rc.1 and this version isn't compatible with compass.
I have sass (3.3.0.rc.1, 3.2.12) installed, so is there a way I can essentially separate the two sass versions so that I can use compass and scss-lint side by side?
Due to the way the SASS dependency is set on both of those projects you cannot run both gems within the same gem set. If you are using scss-lint to do command line linting though, you could just have each of these under separate gem sets and switch between the two as needed. This does not preclude automation.
So the way I got around this was by installing the latest alpha version of compass. This meant that I can now use the two gems together :)

Can I control the version of rubygems that IntelliJ uses?

I'm trying to start a rails application in IntelliJ with the Ruby plugin.
I've imported the application and set up the run configuration as best I can. When I try to run it I get the error:
NoMethodError: undefined method `version_requirements' for #<Gem::Dependency:0x7de21f45>
When looking for an answer I found this page saying that I should do this:
$ gem install rubygems-update -v='1.4.2'
$ gem uninstall rubygems-update -v='1.5.0'
$ update_rubygems
Since it's IntelliJ's ruby plugin that is managing the gems, I assume that I have to change the version of rubygems-update that the plugin is using.
Is this the right approach to take? And if so, can anyone tell me how to go about it?
I tried listing the gems but that gem is not shows so I must not be listing the gems in the right place, but I don't know where to look.
Many thanks :)
IntelliJ IDEA cannot handle it, you will need to install the appropriate rubygems version from the command line.
Note that your current rubygems-update version may be different, verify it with gem list and use the reported version when uninstalling.

Could not find gem 'rubytree (~> 0.5.2) ruby' while installing ChiliProject on Debian

I am trying to install chiliproject on a server, following the -well done- documentation I am hitting this error
Could not find gem 'rubytree (~> 0.5.2) ruby' in any of the gem sources listed in your Gemfile.
I did a gem install rubytree
I get this message
========================================================================
Thank you for installing rubytree.
WARNING: SIGNIFICANT API CHANGE in 0.8.0 !
------------------------------------------
Please note that as of 0.8.0 the CamelCase method names are DEPRECATED.
The new method names follow the ruby_convention (separated by '_').
The old CamelCase methods still work (a warning will be displayed),
but may go away in the future.
Details of the API changes are documented in the API-CHANGES file.
========================================================================
Successfully installed rubytree-0.8.1
1 gem installed
Installing ri documentation for rubytree-0.8.1...
file 'COPYING,API-CHANGES' not found
Installing RDoc documentation for rubytree-0.8.1...
file 'COPYING,API-CHANGES' not found
That is saying the installation was succesful. So why do I get the error ?
If the error is from the API change how can I request version 0.5.2 of the rubytree gem ?
When I do a gem list --local | grep 'rubytree'
I have this output rubytree (0.8.1)
So why is the system saying could not find gem 'rubytree' ?
thank you for any help,
Depending on what version of rails you are using (and it sounds like you are using a relatively newer one, if it's prompting you for your Gemfile), then you need to use Bundler to manage your gems.
Try editing your Gemfile, adding a new line that reads:
gem "rubytree", "< 0.6"
Then open up a console, and type this command
bundle install
This should fix your problems, but if you still get errors when running a command, then try typing bundle exec prior to the command (i.e. rails server becomes bundle exec rails server).
Currently, we require rubytree exactly in version 0.5.2 or 0.5.3, as specified in our Gemfile, the 0.8.1. version you installed by hand will not suffice that requirement, which is exactly what the error message states.
What seems a bit odd is the literal ruby in the error message. Could you please make sure that you have the exact unchanged Gemfile from the source on your system? Also, could you please remove any user-installed plugins and try again? Also, which ruby (type and version) on which operating system are you using?

Ruby: How to include/install .bundle?

I'm new to Ruby. I have a .bundle file. I put it in the source folder and did
require('my.bundle')
But when I call the methods in the bundle, the definition is not found. Do I have to install them or include them in some other way to access them?
I am on Ruby version 1.8.7 (latest version on Mac).
I highly recommend using RVM to manage your Ruby installation, including your gems, so if you don't already have that, get it and follow the instructions for installing it. Make sure you do the part about modifying your bash startup script or you'll see weird behavior, like the wrong Ruby being called. Also, use the steps in "RVM and RubyGems" to install your gems or you can run into weird behavior with gems being installed under the wrong or an unexpected Ruby.
Second, use the gem command to install gems:
gem install gem_to_install
replacing "gem_to_install" with the name of the gem you want, and it will be installed into the appropriate gem folder for your Ruby.
If you are on Ruby 1.92, and trying to require a gem to use as a module in your code, use:
require 'gemname'
if it is installed via the gem command. And, if it is a module you wrote or have in your program's directory or below it, use:
require_relative 'path/to/gem/gemname'
If you are on a Ruby < 1.9 you'll also need to add require 'rubygems' above your other require lines, then use require './path/to/gem/gemname'.
Thanks, but my .bundle is not in gems. How do I install/require a .bundle file I already have?
If you wrote it look into rubygems/gemcutter or bundler for info on bundling and managing gems.
You can install a gem without using the app by going into the directory containing the gem and running setup.rb. See http://i.loveruby.net/en/projects/setup/doc/usage.html for a decent writeup or the official docs at: http://docs.rubygems.org/read/chapter/3

Resources