Is it possible to require sass via composer? - sass

I see in composer you can specify "php": ">=5.3" as a requirement so I've tried doing
`"sass": "*"`
and I get a no matching package found error when I try to update my dependencies.
Is it possible to do something like this?

I do not think so. Composer is a PHP package manager written in PHP, while Sass is a Ruby tool. In addition, Ruby has its own package manager: RubyGems.
If you want to manage versions of Sass, I invite you to use Bundler and Gemfile.

Related

Ruby: CLI script failing when requiring gems installed through git

I am patching a script, and want to run code from a repo I manage that has patches.
The gem in question is not installed through a published gem but through a github link
When requiring any gem that is normally installed. The script works. But requiring any gem that is installed through a github link fails. Any suggestions?
If I understand the problem correctly, there are a few solutions:
Clone the gem that's only available via the github link, build the gem locally, install it. You should be able to require it
You might be able to manage the project with bundler and a Gemfile. Instructions here for the syntax. Bundler basically does what I suggested above, for you. I don't think gem can install a gem from a remote natively?
Would love to see some more clarification, and if you're using a Gemfile the relevant snippets
So the issue was I was running the script in question using ./bin/path/script
This will not work if the script includes github referenced gems, you need to prefix this with bundle exec which is not immediately obvious, given that when you use non-github referenced gems, it works fine without it.
Now running bundle exec ./bin/path/script will work for both, it's probably just better using that wherever possible.

Ruby - Can I import a gem under an alias to avoid dependency issues?

I'm new to Ruby, and am working on a project that has a Gemfile like so:
Gemfile
require_relative 'gem_source_url'
gem_source_url = GemSourceUrl.get_source_url
source gem_source_url do
gem 'jwt'
gem 'some_other_lib'
end
My problem is that the gem some_other_lib, includes a version of jwt that is too old (1.5.6), and I can't use, but I can't change anything to do with that gem.
Can I somehow import a newer version of jwt gem under an alias (2.1.0), so I can use the newer version?
Likely not really possible without some dirty code since importing two versions of the same gem would mean that in practice you would be using two versions of the same class (JWT in this case). A better approach would be to ask the makers of some_other_lib to update their dependencies or, if it's no longer being maintained, fork and update yourself and then put out the updated version for the benefit of the community.
Edit: For more info on the conflicting classes, see Use 2 versions of gem at same time

Installing Compass & Sass on Dreamhost

I would like to get going with Compass and Sass on my Dreamhost webspace. Unfortunately it is not part of the provided standard gems so the installation appears to be more complicated. Does anyone have hands on experience with installing and running Compass and Sass on Dreamhost?
I'd appreciate any guidance.
I was facing a similar challenge - installing Sass/Compass on dreamhost shared account - but was able to figure out how to do it. I used these instructions for installing my own copy of RubyGems (although I'm not completely sure that was necessary). Then I just used the following two commands to install sass and compass:
gem install sass
gem install compass
It all went pretty smoothly.
One option is to just precompile your sass (compass compile) on your machine and then upload just the CSS, so you don't actually need compass installed there.
Or, if you're in a ruby project, use bundler. It will install the gems under the project.
If you're using a Dreamhost VPS (I would recommend it over the shared hosting) then you also have sudo access, and you can install it globally by logging in as an admin user (set this up in the panel).

Easiest way to get Compass/Sass running on OSX

I first had to follow the instructions here to make sure that I had Ruby and Gems installed. Then I installed compass using Gems.
Then I tried to run compass and had some errors...
"Warning: Unable to load CarbonCore.
FSEvents will be unavailable compass"
I found a solution here, but it required me to install RVM via gems first and then following the instructions in the link above.
Is there an easier way to setup/run compass/sass on OSX?
This problem is described in the compass issue tracker. It's not a showtopper because it falls back to another (less efficient) method of watching for file changes that doesn't depend of fsevents. Still, it would be nice to fix, right?
Since you compiled your own version of ruby, you need to enable shared libraries for it as well. This is described on the rubycocoa getting started page.
More details can be found in this google groups discussion, particularly the advice from Brandon Mathis.
Installing last version of Compass gem (0.11.5) seems to solve the problem:
gem install compass
You have to update your gems:
sudo gem update –system

Manually adding a Ruby Gem

I am trying to install the mechanize gem that is supposed to work with 1.9 from here: http://github.com/kemiller/mechanize but I do not know how to add it manually.
I am using Windows, I could just copy the folder to the gems directory, but how do I initialize it?
I'm not sure I understand the problem. gem install mechanize doesn't work? It produces version 0.9.3 for me, which matches the gemspec of the library you linked to.
EDIT: you're on 1.9. I knew that. Disregard my hasty post, not familiar enough with Windows to offer any help on building the extensions.
I would use the bundler gem using the command gem install bundler. This will create a file called Gemfile in your project directory where you can put your dependencies for the specific project that you are working on. In the Gemfile, you will need to specify gem mechanize. If you want a specific version include ~> VERSION after. After, run the command bundle install. This will install the gem you want and use it in your project.

Resources