Using lessc on Windows - less

I've been trying to work out how to install lesscss.org on Windows 7 so I can use it from a cygwin command line interface and also using Maven.
We have SASS running in this way but there is a requirement to use LESS in a new project.
My Steps so far...
Checked Ruby is installed, I have it installed at C:\Ruby193
Downloaded the Ruby DevKit and followed this to install it.
At CMD.exe, execute gem install less - 1 gem installed ... less-2.2.1
CMD.exe, run lessc - This gives [WARNING] Please install gem 'therubyracer' to use Less.
So at CMD.exe I try gem install therubyracer which gives this error...
ERROR:
Error installing therubyracer: ERROR: Failed to build gem native extension.
Full error is here
6. And this is where I'm stuck because lessc is still complaining therubyracer is not installed. I've also installed Python27 and added it to the Path variable as that came up in a previous error.
I can confirm I have this path C:\Ruby193\lib\ruby\gems\1.9.1\gems\therubyracer-0.10.1 which looks like a project to me but something is obviously wrong.
I've also found this as a potential answer to getting LESS on Windows but that would indicate we can't get the native 'real' version to run so both Macs, Windows and Ubuntu can use the same switches/ environment? github.com/duncansmart/less.js-windows

As the others mentioned, this is now easily done with node:
npm install -g less
This will install less as a global module that you can use from anywhere on the command line by typing:
lessc input-file.less output-file.css
An even easer way to do this is to just use a tool like SimpleLess that will automagically compile and minify your LESS for you:
http://wearekiss.com/simpless
Happy Coding!

Perhaps you had the same problem I did where you successfully installed the node module via:
npm install -g less
but when trying to run lessc, you were getting the error:
[WARNING] Please install gem 'therubyracer' to use Less.
I think this is because, though you've installed the node module, the lessc command is still tied to the ruby gem. Try uninstalling the less gem:
gem uninstall less
And then try running lessc again.

Related

Shopify CLI seems unable to find Ruby on Mac

I installed shopify-cli using homebrew on my Mac and tried verifying the installation by running shopify version, but I get an error:
/usr/local/bin/shopify: line 2: /opt/homebrew/Cellar/ruby/3.0.1/bin/ruby: No such file or directory
Any idea what needs to be fixed?
Try running brew install ruby#3.0. It worked for me!
It appears that shopify-cli was installed when your Homebrew ruby was at version 3.0.1. This can be fixed by running the following command:
brew reinstall shopify-cli
(Ideally, the shopify-cli formula should be updated by its maintainers to replace hardcoded ruby paths to the version-agnostic /opt/homebrew/opt/ruby. Alternatively, they could track the Homebrew ruby version and bump the revision of shopify-cli whenever an update occurs. This will prompt end-users to run brew upgrade, which will automatically reinstall shopify-cli.)

YAML safe loading is not available

When I want to install compass with gem install compass, I occurred with this error:
YAML safe loading is not available.
Please upgrade psych to a version that supports safe loading (>= 2.0).
what The cause of this error and how can I solve the problem?
It sounds like the psych gem needs to be updated. Try running gem install psych and then gem update psych.
Suggested by looking at the psych readme file here: https://github.com/ruby/psych/blob/master/README.md
EDIT: you might also have to update your version of ruby. This depends on how you have installed ruby, but #ewerx has one suggestion in their answer.
To resolve this I first upgraded Ruby from 2.0.x to 2.4.2 (https://gorails.com/setup/osx/10.12-sierra):
rbenv install 2.4.2;
rbenv global 2.4.2
Then updated gems:
sudo gem update --system;
gem update
It may be sufficient to just update gems.
The following part of the post on https://gorails.com/setup/osx/10.12-sierra solved my issue.
We will be setting up a Ruby on Rails development environment on macOS 10.12 Sierra.
Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them.
Installing Homebrew
First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source.
Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes.
Open Terminal and run the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
Choose the version of Ruby you want to install:
Now that we have Homebrew installed, we can use it to install Ruby.
We're going to use rbenv to install and manage our Ruby versions.
To do this, run the following commands in your Terminal:
brew install rbenv ruby-build
Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Install Ruby
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v

Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0

The command rails server throws this error.
C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load
such file -- mysql2/2.0/mysql2 (LoadError)
I use Ruby 2.0.0 from RubyInstaller on Windows XP box.
I figured out what is the problem but I don't know how to solve it. The problem is that there is no any 2.0/ directory in the mysql2-0.3.11-x86-mingw32 gem. This is the gem that rails installs as its dependency from Gemfile:
GEM
remote: https://rubygems.org/
specs:
... many gems here
mysql2 (0.3.11-x86-mingw32)
... many gems here
DEPENDENCIES
...
mysql2
...
This is what is in that mysql2.rb file:
# C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\mysql2.rb
RUBY_VERSION =~ /(\d+.\d+)/
require "mysql2/#{$1}/mysql2" # <<-- this is that #2 line that throws an error
It is obvious that it takes the current Ruby version number and uses it as the path segment to reach some mysql2 file. In fact it is mysql2.so file. As I use Ruby 2.0.0 the path segment is 2.0:
mysql2/2.0/mysql2
Ok, now lets see how that directory of mysql2-0.3.11-x86-mingw32 gem looks like:
dir: C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\
No any 2.0/ directory.
I know the issue about libmysql.dll. I have it in my C:\Ruby200\bin. It doesn't help.
I read this answer https://stackoverflow.com/a/5368767/1114926 from the creator of RubyInstaller. I tried but it didn't help. It works for Ruby 1.9.3 because there is 1.9/ directory. But it doesn't work for Ruby 2.0.0.
How to solve it?
UPD 1:
Thank you for your answer. I've tried. Unfortunately I have ERROR: Failed to build gem native extension. error:
C:\>gem install mysql2 --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby200/bin/ruby
C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed to generate an executable file. (Runtim
eError)
You have to install development tools first.
... other code follows here...
It says:
You have to install development tools first.
But I have full DevKit installed, RubyInstaller installs it. Can't understand what else does it need.
I've already posted an issue to mysql2 GitHub page https://github.com/brianmario/mysql2/issues/364. No answers yet.
Had the absolutely same issue on Windows 7 x64 with Ruby 2.0.0 and DevKit 4.7.
The following steps helped me.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-dir="C:\connector-6.0.2"'
Or even shorter:
gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"
uninstall mysql2-0.3.11-x86-mingw32, gems compiled before Ruby200 won't work. You have to compile it yourself.
If you run gem uninstall mysql2 and there is a non compiled version listed then just uninstall mysql2-0.3.11-x86-mingw32 - the compiled version else...
Installation
gem install mysql2 --platform=ruby. that would work.
Follow this guide on installing devkit http://rubyonwindowsguides.github.com/book/ch02-04.html.
Then try again.
Exactly the same behavior when I try to install Redmine on windows XP
when I try to do the "rake generate_secret_token", I got "cannot load
such file -- mysql2/2.0/mysql2 (LoadError)"
and when I try to re build mysql2 using --platform=ruby, I got the
same message as you green.
for the moment, I am stucked there ... but if anybody has anything to allow me to move forward, it will be very welcome.
I will keep informed as well
antoine
I almost done the same what #odiszapc described. Uninstall old gem, download mysql-connector-c-noinstall, unzip, but finally I used this command to build native gem:
gem install mysql2 --platform=ruby -- --with-opt-dir=/c/connector-6.0.2
(If you use git-bash then you can use unix style directory syntax.)
Copy paste from that link: https://github.com/brianmario/mysql2/issues/359. It worked for me.
If after installing the gem, you get an error:
"The specified module could not be found.
C:/Devel/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/mysql2.so"
That can be fixed by copying libmysql.dll to Ruby's bin folder.

Capistrano + RVM rvm_install_ruby with Rubinius

I am trying to fully automate the setup of my deployment host, and so avoiding manual install of Ruby.
I am using capistrano-rvm as it promises to do the job, but I have a problem when RVM compiles Rubinius:
** [out] rbx-2.0.0pre - #configuring
** [out] rbx-2.0.0pre - #compiling
*** [err] Error running '/home/app/.rvm/wrappers/ruby-1.8.7-p358/rake install', please read /home/app/.rvm/log/rbx-2.0.0pre/rake.log
The content of /home/app/.rvm/log/rbx-2.0.0pre/rake.log is:
ERROR: Gem rake is not installed, run `gem install rake` first.
How could I? That should have been done by RVM, no?
Does anyone already met & get out of this issue?
EDIT
I forgot to mention that RVM did load & compile 1.8.7 before rbx, seems like a dependence for build. Maybe RVM is running in a gem set which is badly initialized?
I thought the 2.0.0pre was removed from rbx already, it looks like you have older RVM installation, make sure you update RVM:
curl -L get.rvm.io | bash -s stable --auto
rvm reload
This will run the installer which also makes update.
To make sure everything works properly use rbx-2.0.testing which is supposed to work version of rbx.

RVM: Incorrect Ruby version referenced after removal

Just updated the version of Ruby (1.9.2 to 1.9.3) I have installed but now getting the following error when running rake:
$ rake
-bash: /Users/mike.simmonds/.rvm/gems/ruby-1.9.3-p0/bin/rake: /Users/mike.simmonds/.rvm/rubies/ruby-1.9.2-p180/bin/ruby: bad interpreter: No such file or directory
Any tips?
It appears reinstalling the rake gem has fixed it.
looks like a gem pristine task failed and you had older rvm, I have already changed the upgrade code to run upgrade for every gem separately and report you list of failed gems.
It's important to read outputs of rvm, even we try to automate things and make things very easy - sometimes there is not much we can do with the available tools.